BigInteger.ToString Method (IFormatProvider)


Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified culture-specific formatting information.

Namespace:   System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

Public Function ToString (
	provider As IFormatProvider
) As String


Type: System.IFormatProvider

An object that supplies culture-specific formatting information.

Return Value

Type: System.String

The string representation of the current BigInteger value in the format specified by the provider parameter.

The ToString(IFormatProvider) method formats a BigInteger value in the "R", or round-trip, format by using the NumberFormatInfo object of a specified culture. If you want to specify a different format or the current culture, use the other overloads of the ToString method, as follows:

To use format

For culture

Use the overload

Round-trip ("R") format

Default (current) culture


A specific format

Default (current) culture


A specific format

A specific culture

ToString(String, IFormatProvider)

The provider parameter is an IFormatProvider implementation. Its GetFormat method returns a NumberFormatInfo object that provides culture-specific information about the format of the string returned by this method. If provider is null, the BigInteger value is formatted using the NumberFormatInfo object of the current culture. The only property of the NumberFormatInfo object that controls the string representation of the BigInteger value using the general format specifier is NumberFormatInfo.NegativeSign, which defines the character that represents the negative sign.

The provider parameter can be one of the following:

The following example instantiates a custom NumberFormatInfo object that defines the tilde (~) as a negative sign. The ToString(IFormatProvider) method then uses the custom NumberFormatInfo object to display a negative BigInteger value.

Dim number As BigInteger = 9867857831128
number = BigInteger.Pow(number, 3) * BigInteger.MinusOne

Dim bigIntegerProvider As New NumberFormatInfo()
bigIntegerProvider.NegativeSign = "~"      


Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 4.0
Windows Phone
Available since 8.1
Return to top