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::ToDecimal Method (Int64)

 

Converts the value of the specified 64-bit signed integer to an equivalent decimal number.

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

public:
static Decimal ToDecimal(
	long long value
)

Parameters

value
Type: System::Int64

The 64-bit signed integer to convert.

Return Value

Type: System::Decimal

A decimal number that is equivalent to value.

The following example converts an Int64 value to a Decimal value.

public:
   void ConvertLongDecimal( Int64 longVal )
   {
      Decimal decimalVal;

      // Long to decimal conversion cannot overflow.
      decimalVal = System::Convert::ToDecimal( longVal );
      System::Console::WriteLine( " {0} as a decimal is {1}",
         longVal, decimalVal );

      // Decimal to long conversion can overflow.
      try
      {
         longVal = System::Convert::ToInt64( decimalVal );
         System::Console::WriteLine( " {0} as a long is {1}",
         decimalVal, longVal );
      }
      catch ( System::OverflowException^ ) 
      {
         System::Console::WriteLine( "Overflow in decimal-to-long conversion." );
      }
   }

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