C# BigInteger Parse(String, IFormatProvider)
Description
BigInteger Parse(String, IFormatProvider)
Converts
the string representation of a number in a specified culture-specific format
to its BigInteger equivalent.
Syntax
BigInteger.Parse(String, IFormatProvider)
has the following syntax.
public static BigInteger Parse(
string value,
IFormatProvider provider
)
Parameters
BigInteger.Parse(String, IFormatProvider)
has the following parameters.
value
- A string that contains a number to convert.provider
- An object that provides culture-specific formatting information about value.
Returns
BigInteger.Parse(String, IFormatProvider)
method returns A value that is equivalent to the number specified in the value parameter.
Example
using System;/*from w w w. j av a 2s. c o m*/
using System.IO;
using System.Numerics;
using System.Globalization;
public class Example
{
public static void Main()
{
BigInteger number = BigInteger.Parse("~123123123123", new BigIntegerFormatProvider());
Console.WriteLine(number.ToString(new BigIntegerFormatProvider()));
}
}
public class BigIntegerFormatProvider : IFormatProvider
{
public object GetFormat(Type formatType)
{
if (formatType == typeof(NumberFormatInfo))
{
NumberFormatInfo numberFormat = new NumberFormatInfo();
numberFormat.NegativeSign = "~";
return numberFormat;
}
else
{
return null;
}
}
}
The code above generates the following result.