Decimal.MinValue
is a field in C# that represents the smallest possible value of decimal
. It is a constant field and read-only, which means that it cannot be modified.
public static readonly decimal MinValue;
This field returns the value -79,228,162,514,264,337,593,543,950,335
.
// use Systemusing System;// create classclass DecimalMinValue{// main methodstatic void Main(){// print the field valueConsole.WriteLine(Decimal.MinValue);}}
Decimal.MinValue
field to the console.If there is a decimal value that is less than the Decimal.MinValue
, the field will throw an error, as this is the minimum value a decimal can be.
// use Systemusing System;// create classclass DecimalMinValue{static void Main(){// add to another// decimal valuedecimal newDecimalNumber = -1.0m + Decimal.MinValue;// print resultConsole.WriteLine(newDecimalNumber);}}
-1.0
and Decimal.MinValue
. This will throw an error because no decimal value is supposed to be less than the Decimal.MinValue
field.