NumberStyles and BigInteger parse
using System;
using System.Globalization;
using System.Numerics;
public class Example
{
public static void Main()
{
BigInteger number;
number = BigInteger.Parse(" -6 ", NumberStyles.Integer);
Console.WriteLine(number);
number = BigInteger.Parse("6", NumberStyles.AllowHexSpecifier);
Console.WriteLine(number);
try
{
number = BigInteger.Parse(" -6 ", NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite);
Console.WriteLine(number);
}
catch (FormatException e)
{
Console.WriteLine(e.Message);
}
try
{
number = BigInteger.Parse(" 99999 ", NumberStyles.AllowLeadingSign);
Console.WriteLine(number);
}
catch (FormatException e)
{
Console.WriteLine(e.Message);
}
}
}
Related examples in the same category