Convert. toint32, Int. parse (int32.parse), Int. tryparse, and (INT) can all be interpreted as converting data types to int. What are the differences between them?
Convert. toint32AndInt. parseSimilarly, convert. toint32 actually calls Int. parse:
- 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 convert numeric strings.
Int. tryparseSimilar to int. parse, but it does not produce exceptions. If the conversion is successful, true is returned, and if the conversion fails, false is returned. The last parameter is the output value. If the conversion fails, the output value is 0.
(INT)Cast conversion: only other numeric types can be converted to int type. It cannot be converted to strings. For example, the following example will fail:
String v = "1 ";
Int n = (INT) V;