Decimal constants in C#


Decimal type has constants to get the minimum and maximum values.

Set a decimal value −

decimal d = 5.8M;

To get the minimum and maximum values of the decimal type, use the following properties −

decimal.MaxValue
decimal.MinValue

Here is the complete code −

Example

 Live Demo

using System;
using System.Linq;
class Demo {
   static void Main() {
      decimal d = 5.8M;
      Console.WriteLine(d);
      Console.WriteLine("Maximum Value: "+decimal.MaxValue);
      Console.WriteLine("Maximum Value: "+decimal.MinValue);
   }
}

Output

5.8
Maximum Value: 79228162514264337593543950335
Maximum Value: -79228162514264337593543950335

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 22-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements