C# UInt64 Parse(String)
Description
UInt64 Parse(String)
converts the string representation
of a number to its 64-bit unsigned integer equivalent.
Syntax
UInt64.Parse(String)
has the following syntax.
[CLSCompliantAttribute(false)]
public static ulong Parse(
string s
)
Parameters
UInt64.Parse(String)
has the following parameters.
s
- A string that represents the number to convert.
Returns
UInt64.Parse(String)
method returns A 64-bit unsigned integer equivalent to the number contained in s.
Example
The following example uses the Parse method to parse an array of string values.
/*ww w . j av a2 s. co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
string[] values = { "+12340", "-0", "1,2234567", "$123,456,456,567",
"0xFA1B", "123042", "-10", "12345678902",
"16e07", "123456.0", "-12034" };
foreach (string value in values)
{
try {
ulong number = UInt64.Parse(value);
Console.WriteLine("{0} --> {1}", value, number);
}
catch (FormatException) {
Console.WriteLine("{0}: Bad Format", value);
}
catch (OverflowException) {
Console.WriteLine("{0}: Overflow", value);
}
}
}
}
The code above generates the following result.