Converts a string representation of a value to a UInt16 with the NumberStyles enumeration. The UInt16 type is not CLS compliant. The CLS-compliant alternative is Int16.
[C#] public static ushort Parse( string s, NumberStyles style ); [C++] public: static unsigned short Parse( String* s, NumberStyles style ); [JScript] public static function Parse( s : String, style : NumberStyles ) : UInt16;
[Visual Basic] The UInt16 type cannot be used in Visual Basic.
A UInt16 with the value represented by s.
Exception Type | Condition |
---|---|
ArgumentException | If the style is not a NumberStyles enumeration. |
ArgumentNullException | If the string is a null reference (in Visual Basic Nothing). |
FormatException | If the string is not of the correct format. |
OverflowException | If the string represents a number that is less than MinValue or greater than MaxValue. |
The numeric format information is obtained from the current locale. If s has been created by one of the Format methods using C, D, E, F, G, or N as the format specifier, it is guaranteed that s can be parsed when style is Any of NumberStyles.
The style parameter must be a combination of bit flags from the NumberStyles enumeration.
Note Hexadecimal strings ("0x42") are not supported. Use the Convert ToIntxx(string, int) and ToUIntxx methods for the conversions. ReplaceThisText
Note The Parse methods do not accept not a number (NaN) or positive or negative infinity.
UInt16 Structure | UInt16 Members | System Namespace | UInt16.Parse Overload List | String | NaN | NaN | PositiveInfinity | PositiveInfinity | NegativeInfinity | NegativeInfinity | Value | Convert