. NET type transformation four kinds of practices:
Forced transformation: (int) variable name
Int. Parse (string variable name)
Convert.to type (variable name)
TryParse
Compulsory transition (casting)
Floating point numbers do unconditional, lose precision
Can handle an object to int, but an error occurs when an object is null
In some cases, such as object transformation into an int, sometimes normal, but sometimes for no reason error, unexplained
Unable to process string int (functions often used in the program)
Never be used to handle char types, otherwise the ASCII code is returned instead of the literal number
Int. Parse (string variable name)
can only handle string int or other types, cannot handle types other than string, limited functionality
String was encountered as null or string. Empty will still cause the error of the program
can also change the use of: "Type." Parse (String), but parameters can only be dropped string
Convert.to type (variable name)
can handle all. NET types, functional integrity
can handle NULL, almost no program error due to transformation
When transformed into int by "convert.toint32 (variable), the variable is of type object or string, and when its value is null, it returns 0, without causing the program error
Last, if this string type has a variable whose original value is string. Empty, when converted to int, still cause program error
Floating-point numbers are rounded.
Never be used to handle char types, otherwise the ASCII code is returned instead of the literal number