Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Convert.ToString Method (Decimal)

 

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

Namespace:   System
Assembly:  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);
}	

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft