UInt16TryParse Method (String, NumberStyles, IFormatProvider, UInt16) |
Tries to convert the string representation of a number in a specified style and culture-specific format to its 16-bit unsigned integer equivalent. A return value indicates whether the conversion succeeded or failed.
Namespace: SystemAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public static bool TryParse(
string s,
NumberStyles style,
IFormatProvider provider,
out ushort result
)
Parameters
- s
- Type: SystemString
A string that represents the number to convert. The string is interpreted by using the style specified by the style parameter. - style
- Type: System.GlobalizationNumberStyles
A bitwise combination of enumeration values that indicates the permitted format of s. A typical value to specify is Integer. - provider
- Type: SystemIFormatProvider
An object that supplies culture-specific formatting information about s. - result
- Type: SystemUInt16
When this method returns, contains the 16-bit unsigned integer value equivalent to the number contained in s, if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null, is not in a format compliant with style, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized.
Return Value
Type:
Booleantrue if
s was converted successfully; otherwise, false.
Exceptions Exception | Condition |
---|
ArgumentException | style is not a NumberStyles value. -or-style is not a combination of AllowHexSpecifier and HexNumber values. |
See Also