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
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