Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

BigInteger.ToString Method

Converts the numeric value of the current BigInteger object to its equivalent string representation.

Namespace:  System.Numerics
Assemblies:   System.Runtime.Numerics (in System.Runtime.Numerics.dll)
  System.Numerics (in System.Numerics.dll)

public override string ToString()

Return Value

Type: System.String
The string representation of the current BigInteger value.

The ToString() method formats a BigInteger value in the default ("G", or general) format of the current culture. If you want to specify a different format or culture, use the other overloads of the ToString method, as follows:

To use format

For culture

Use the overload

Default ("G") format

A specific culture


A specific format

Default (current) culture


A specific format

A specific culture

ToString(String, IFormatProvider)

The string representation of the BigInteger value includes a negative sign if its value is negative, and a sequence of digits ranging from 0 to 9 without leading zeros. The negative sign is defined by the NumberFormatInfo object for the current culture.

The ToString() method supports 50 decimal digits of precision. That is, if the BigInteger value has more than 50 digits, only the 50 most significant digits are preserved in the output string; all other digits are replaced with zeros.

The following example displays a BigInteger value by using the default ToString() method. It also displays the string representations of the BigInteger value that results from using some standard format specifiers. The examples are displayed using the formatting conventions of the en-US culture.

// Initialize a BigInteger value.
BigInteger value = BigInteger.Add(UInt64.MaxValue, 1024);

// Display value using the default ToString method.
// Display value using some standard format specifiers.
// The example displays the following output on a system whose current  
// culture is en-US: 
//       18446744073709552639 
//       18446744073709552639 
//       $18,446,744,073,709,552,639.00 
//       18446744073709552639 
//       18446744073709552639.00 
//       18,446,744,073,709,552,639.00 
//       100000000000003FF      

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Portable Class Library

Supported in: Portable Class Library
© 2015 Microsoft