This documentation is archived and is not being maintained.

Decimal.ToString Method ()

Converts the numeric value of this instance to its equivalent string representation.

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

public override string ToString ()
public String ToString ()
public override function ToString () : String
Not applicable.

Return Value

A string that represents the value of this instance.

The return value is formatted with the general numeric format specifier ("G"), and the NumberFormatInfo object for the current culture. To define the formatting of the decimal value's string representation, call the Decimal.ToString(String) method. To define the culture whose formatting is used in the decimal value's string representation, call the Decimal.ToString(IFormatProvider) method. To define both the format specifiers and culture used in creating the string representation of a decimal value, call the Decimal.ToString(String,IFormatProvider) method.

The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

The following example displays a Decimal value using the default ToString method. It also displays the string representations of the Decimal value that result from using a number of standard format specifiers.

The following example displays the amount of money in an account.

class PiggyBank {
    public void AddPenny() {
        MyFortune = Decimal.Add(MyFortune, .01m);

    public override string ToString() {
        return MyFortune.ToString("C")+" in piggy bank";

    protected decimal MyFortune;

class PiggyBank
    public void AddPenny()
        myFortune = System.Decimal.Add(myFortune, 
    } //AddPenny

    public String ToString()
        return myFortune.ToString("C") + " in piggy bank";
    } //ToString

    protected System.Decimal myFortune;
} //PiggyBank

class PiggyBank {
    protected var MyFortune : Decimal;

    public function AddPenny() {
        MyFortune = Decimal.Add(MyFortune, 0.01);

    public function ToString() : String {
        return MyFortune.ToString("C")+" in piggy bank";

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0