Converts the string representation of a number to its BigInteger equivalent.
using System;
using System.Numerics;
public class Class1
{
public static void Main()
{
string stringToParse = String.Empty;
try
{
string string1, string2;
string1 = "99999999999999999999";
string2 = "88888888888888888888";
stringToParse = string1;
BigInteger number1 = BigInteger.Parse(stringToParse);
Console.WriteLine("Converted '{0}' to {1:N0}.", stringToParse, number1);
stringToParse = string2;
BigInteger number2 = BigInteger.Parse(stringToParse);
Console.WriteLine("Converted '{0}' to {1:N0}.", stringToParse, number2);
}
catch (FormatException)
{
Console.WriteLine("Unable to parse {0}.", stringToParse);
}
}
}
Related examples in the same category