Mega Code Archive

 
Categories / C# / Data Types
 

Converts the value of the specified Decimal to the equivalent 64-bit signed integer

using System; class MainClass {     public static void DecimalToU_Int64( decimal argument )     {         object Int64Value = null;         object UInt64Value = null;         // Convert the argument to a long value.         try         {             Int64Value = decimal.ToInt64( argument );         }         catch( Exception ex )         {             Int64Value = null;         }         // Convert the argument to a ulong value.         try         {             UInt64Value = decimal.ToUInt64( argument );         }         catch( Exception ex )         {             UInt64Value = null;         }         Console.WriteLine( Int64Value);         Console.WriteLine( UInt64Value );     }     public static void Main( )     {         DecimalToU_Int64( 123M );     } }