Declare decimal variable : decimal « Data Type « C# / CSharp Tutorial






  1. decimal is intended for use in monetary calculations.
  2. decimal utilizes 128 bits to represent values within the range 1E-28 to 7.9E+28.
  3. decimal eliminates the rounding errors caused by the normal floating-point data type.
using System;
using System.Collections.Generic;
using System.Text;

class MainClass
{
    static void Main(string[] args)
    {
        decimal myDecimal = 150;
        double myDouble = 150;
    }
}








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