System.UInt64.Parse Method

Converts the string representation of a number in a specified culture-specific format to its 64-bit unsigned integer equivalent.

Syntax

[System.CLSCompliant(false)]
public static ulong Parse (string s, IFormatProvider provider)

Parameters

s
A string that represents the number to convert.
provider
An object that supplies culture-specific formatting information about s.
s
A string that represents the number to convert.
provider
An object that supplies culture-specific formatting information about s.

Returns

A 64-bit unsigned integer equivalent to the number specified in s.

Exceptions

TypeReason
ArgumentNullException s is a null reference.
FormatException s is not in the correct style.
OverflowException s represents a number greater than ulong.MaxValue or less than ulong.MinValue.

Remarks

This overload of the ulong.Parse(string, IFormatProvider) method is typically used to convert text that can be formatted in a variety of ways to a ulong value. For example, it can be used to convert the text entered by a user into an HTML text box to a numeric value.

The s parameter contains a number of the form:

[ws][sign]digits[ws]

Items in square brackets ([ and ]) are optional. The following table describes each element.

ws

Optional white space.

sign

An optional positive sign, or a negative sign if s represents the value zero.

digits

A sequence of digits ranging from 0 to 9.

The s parameter is interpreted using the System.Globalization.NumberStyles.Integer style. In addition to the unsigned integer value's decimal digits, only leading and trailing spaces along with a leading sign is allowed. (If the negative sign is present, s must represent a value of zero, or the method throws an OverflowException.) To explicitly define the style elements together with the culture-specific formatting information that can be present in s, use the ulong.Parse(string, System.Globalization.NumberStyles, IFormatProvider) method.

The provider parameter is an IFormatProvider implementation whose IFormatProvider.GetFormat(Type) method returns a System.Globalization.NumberFormatInfo object that provides culture-specific information about the format of s. There are three ways to use the provider parameter to supply custom formatting information to the parse operation:

If provider is null, the System.Globalization.NumberFormatInfo for the current culture is used.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0