using
System;
using
System.Globalization;
class
GFG {
public
static
void
Main()
{
try
{
CultureInfo cultures =
new
CultureInfo("en-US");
string
[] values = {"123456789012",
"+123456789012",
"18446744073709551615"};
Console.WriteLine("Converted
ulong
value"
+ " of specified strings: ");
for
(
int
j = 0; j < values.Length; j++)
{
get
(values[j], cultures);
}
Console.WriteLine("\n");
string
s = "123 456, 789";
Console.WriteLine("format of s
is
invalid ");
long
val = Convert.ToUInt64(s, cultures);
Console.Write(" {0}, ", val);
}
catch
(FormatException e)
{
Console.Write("Exception Thrown: ");
Console.Write("{0}", e.GetType(), e.Message);
}
catch
(OverflowException e)
{
Console.Write("Exception Thrown: ");
Console.Write("{0}", e.GetType(), e.Message);
}
}
public
static
void
get
(
string
s,
CultureInfo cultures)
{
ulong
val = Convert.ToUInt64(s,
cultures);
Console.Write(" {0}, ", val);
}
}