Converts a String to a UInt16. The UInt16 type is not CLS compliant. The CLS-compliant alternative is Int16.
[C#] public static ushort Parse( string s ); [C++] public: static unsigned short Parse( String* s ); [JScript] public static function Parse( s : String ) : UInt16;
[Visual Basic] The UInt16 type cannot be used in Visual Basic.
The UInt16 value of the string.
Exception Type | Condition |
---|---|
ArgumentNullException | If the sting is a null reference (in Visual Basic Nothing). |
FormatException | If the string contains a character other than a minus sign ("-") or the digits 0 through 9. |
OverflowException | If s represents a number that is less than MinValue or greater than MaxValue. |
The Parse method converts a String to a UInt16. The string must consist of an optional minus sign ("-") followed by a sequence of digits ("0" through "9").
Leading and trailing white space characters are ignored.
Note Hexadecimal strings ("0x42") are not supported. Use Value or Convert ToIntxx(string, int) and ToUIntxx methods for the conversions.
Note The Parse method does not accept not a number (NaN) or positive or negative infinity.
UInt16 Structure | UInt16 Members | System Namespace | UInt16.Parse Overload List | String | Value | Convert | NaN | NaN | PositiveInfinity | PositiveInfinity | NegativeInfinity | NegativeInfinity