Decimal.ToString() Method in C#


The Decimal.ToString() method in C# is used to convert the numeric value of this instance to its equivalent string representation.

Syntax

Following is the syntax −

public override string ToString ();

Example

Let us now see an example to implement the Decimal.ToString() method −

using System;
public class Demo{
   public static void Main(){
      decimal d = 3444.787m;
      string str = d.ToString();
      Console.WriteLine("String = "+str);
   }
}

Output

This will produce the following output −

String = 3444.787

Example

Let us see another example −

using System;
public class Demo{
   public static void Main(){
      decimal d = 100;
      string str = d.ToString();
      Console.WriteLine("String = "+str);
   }
}

Output

This will produce the following output −

String = 100
raja
Published on 08-Nov-2019 06:47:29
Advertisements