Decimal.ToString Method ()
.NET Framework 2.0
Converts the numeric value of this instance to its equivalent String representation.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly: mscorlib (in mscorlib.dll)
The return value is formatted with the general format specifier ("G"), and the NumberFormatInfo for the current culture.
The following code sample displays the amount of money in an account.
Class PiggyBank Public Sub AddPenny() MyFortune = [Decimal].Add(MyFortune, 0.01D) End Sub Public Overrides Function ToString() As String Return MyFortune.ToString("C") + " in piggy bank" End Function Protected MyFortune As Decimal End Class
class PiggyBank
{
public void AddPenny()
{
myFortune = System.Decimal.Add(myFortune,
System.Convert.ToDecimal(0.01));
} //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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.