Convert BigInteger to string with number formatting information in CSharp

Description

The following code shows how to convert BigInteger to string with number formatting information.

Example


using System;/* w w w  .j  av  a 2 s . c o m*/
using System.Globalization;
using System.Numerics;

public class Example
{
    public static void Main()
    {
        BigInteger number = 999999999999999;
        number = BigInteger.Pow(number, 3) * BigInteger.MinusOne;

        NumberFormatInfo bigIntegerProvider = new NumberFormatInfo();
        bigIntegerProvider.NegativeSign = "~";

        Console.WriteLine(number.ToString(bigIntegerProvider));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var