C# BigInteger ToString(String, IFormatProvider)

Description

BigInteger ToString(String, IFormatProvider) Converts the numeric value of the current BigInteger object to its equivalent string representation by using the specified format and culture-specific format information.

Syntax

BigInteger.ToString(String, IFormatProvider) has the following syntax.


public string ToString(
  string format,
  IFormatProvider provider
)

Parameters

BigInteger.ToString(String, IFormatProvider) has the following parameters.

  • format - A standard or custom numeric format string.
  • provider - An object that supplies culture-specific formatting information.

Returns

BigInteger.ToString(String, IFormatProvider) method returns The string representation of the current BigInteger value as specified by the format and provider parameters.

Example


using System;//from w w w .j a v a2  s.  c  o  m
using System.IO;
using System.Numerics;
using System.Globalization;

public class Example
{
    public static void Main()
    {
        NumberFormatInfo bigIntegerFormatter = new NumberFormatInfo();
        bigIntegerFormatter.NegativeSign = "~";

        BigInteger value = BigInteger.Parse("-123123123123123123123");
        string[] specifiers = { "C", "D", "D25", "E", "E4", "e8", "F0", 
                                "G", "N0", "P", "R", "X", "0,0.000", 
                                "#,#.00#;(#,#.00#)" };

        foreach (string specifier in specifiers)
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier,
                              bigIntegerFormatter));

    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex