Differences in int type conversion and int type conversion
1. (int) is a type conversion. When we convert the nt type to the long, float, double, decimal type, we can use implicit conversion, however, Explicit conversions are required from the long type to the int type. Otherwise, a compilation error occurs.
2. int. Parse () is a type of capacity conversion. It indicates converting the numeric content string to the int type.
If the string is null, an ArgumentNullException exception is thrown;
If the string content is not a number, a FormatException is thrown;
OverflowException is thrown if the number indicated by the string content exceeds the range indicated by the int type;
3. int. TryParse is similar to int. Parse, but it does not produce exceptions. If the conversion is successful, true is returned. If the conversion fails, false is returned.
The last parameter is the output value. If the conversion fails, the output value is 0. If the conversion is successful, the output value is the converted int value.
4. Convert. ToInt32 () is a type-tolerant conversion, but it is not limited to converting a string to the int type, or it can be another type of parameter;
Comparison: If the Convert. ToInt32 parameter is null, 0 is returned; if the int. Parse parameter is null, an exception is thrown. If the Convert. ToInt32 parameter is "", an exception is thrown. If the int. Parse parameter is "", an exception is thrown. Convert. ToInt32 can be converted to many types. int. Parse can only be converted to numeric strings.