Converts a String to an Int32.
[Visual Basic] Overloads Public Shared Function ToInt32( _ ByVal value As String _ ) As Integer [C#] public static int ToInt32( string value ); [C++] public: static int ToInt32( String* value ); [JScript] public static function ToInt32( value : String ) : int;
An Int32 with the value represented by value .
Exception Type | Condition |
---|---|
ArgumentException | If value is null. |
FormatException | Is thrown if value does not contain a reprsentation that can be converted to an Int32 using the Parse(String) method implemented by that type. |
OverflowException | if value represents a number that is less than Int32.MinValue or greater than Int32.MaxValue. Note that if the beginning of the string value contains a properly formatted numerical value that will result in an overflow and, in addition, the end of the string is improperly formed, it cannot be determined whether an OverflowException or a FormatException will be thrown. This has been implemented this way for performance reasons. |
value is parsed as a decimal unless it is preceded by 0x, in which case it is parsed as a hexadecimal number. White space or trailing characters will cause a FormatException.
Convert Class | Convert Members | System Namespace | Convert.ToInt32 Overload List