Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ToString Method (Decimal)

Convert.ToString Method (Decimal)

Converts the value of the specified decimal number to its equivalent string representation.

Namespace:  System
Assemblies:   System.Runtime.Extensions (in System.Runtime.Extensions.dll)
  mscorlib (in mscorlib.dll)

public static string ToString(
	decimal value
)

Parameters

value
Type: System.Decimal

The decimal number to convert.

Return Value

Type: System.String
The string representation of value.

This implementation is identical to Decimal.ToString().

The following example converts a Decimal to a String.

		public void ConvertStringDecimal(string stringVal) {
			decimal decimalVal = 0;
			
			try {
				decimalVal = System.Convert.ToDecimal(stringVal);
				System.Console.WriteLine(
					"The string as a decimal is {0}.", decimalVal);
			} 
			catch (System.OverflowException){
				System.Console.WriteLine(
					"The conversion from string to decimal overflowed.");
			}
			catch (System.FormatException) {
				System.Console.WriteLine(
					"The string is not formatted as a decimal.");
			}
			catch (System.ArgumentNullException) {
				System.Console.WriteLine(
					"The string is null.");
			}

			// Decimal to string conversion will not overflow.
			stringVal = System.Convert.ToString(decimalVal);
			System.Console.WriteLine(
				"The decimal as a string is {0}.", stringVal);
		}	

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft