Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

BigInteger.ToString Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Numerics
Assembly:  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 "R", or round-trip, 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

Round-trip ("R") format

A specific culture

ToString

A specific format

Default (current) culture

ToString(String)

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 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.
Console.WriteLine(value.ToString());     
// Display value using some standard format specifiers.
Console.WriteLine(value.ToString("G"));
Console.WriteLine(value.ToString("C"));
Console.WriteLine(value.ToString("D"));
Console.WriteLine(value.ToString("F"));
Console.WriteLine(value.ToString("N"));
Console.WriteLine(value.ToString("X"));       
// 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      

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