Manually create a decimal number. : decimal « Data Type « C# / CSharp Tutorial






Decimal offers eight public constructors.

The following six are the most commonly used:

  1. public Decimal(int v)
  2. public Decimal(uint v)
  3. public Decimal(long v)
  4. public Decimal(ulong v)
  5. public Decimal(float v)
  6. public Decimal(double v)
  7. 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:

  1. IComparable,
  2. IConvertible, and
  3. IFormattable.
using System;  
  
class MainClass {     
  public static void Main() {     
    decimal d = new decimal(12345, 0, 0, false, 2); 
 
    Console.WriteLine(d); 
  }     
}
123.45








2.30.decimal
2.30.1.Declare decimal variable
2.30.2.To specify a decimal constant, begin the specification with a nonzero digit.
2.30.3.Manually create a decimal number.
2.30.4.The Methods and Fields Defined by Decimal
2.30.5.decimal literal
2.30.6.decimals and arithmetic operators
2.30.7.Decimal ranges
2.30.8.Specifying a Literal decimal
2.30.9.decimal Types