Manually create a decimal number. : Decimal : Data Type C# Examples


C# Examples » Data Type » Decimal »

 

Manually create a decimal number.





Decimal offers eight public constructors.
The following six are the most commonly used:

public Decimal(int v)
public Decimal(uint v)
public Decimal(long v)
public Decimal(ulong v)
public Decimal(float v)
public Decimal(double v)
public Decimal(int low, int middle, int high, bool signFlag, byte scaleFactor)

You can specify the constituents of a Decimal in an array of integers, using this constructor:




    
public  Decimal(int[  ]  parts)
    
   
  
   

Decimal implements the following interfaces:

IComparable,
IConvertible, and
IFormattable.





    
using  System;    
    
class  MainClass  {          
    public  static  void  Main()  {          
        decimal  d  =  new  decimal(12345,  0,  0,  false,  2);  
  
        Console.WriteLine(d);  
    }          
}
    
   
  
   



Output

123.45


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Decimal