What is the MinusOne field of decimal in C#?
Overview
Decimal.MinusOne is a decimal field in C#. It represents the number negative one (-1).
Syntax
public static readonly decimal MinusOne;
Syntax for Decimal.MinusOne field
Return value
The value returned is minus one (-1).
Code example
// use Systemusing System;// create classclass HelloWorld{static void Main(){// print the fieldConsole.WriteLine(Decimal.MinusOne);// create decimal valuesdecimal decimalNumberOne = Decimal.MinusOne;decimal decimalNumberTwo = 3.4m + Decimal.MinusOne;decimal decimalNumberThree = 10.00m / Decimal.MinusOne;// print valuesConsole.WriteLine(decimalNumberOne);Console.WriteLine(decimalNumberTwo);Console.WriteLine(decimalNumberThree);}}
Explanation
- Line 9: We print the value of the field
Decimal.MinusOne. - Lines 12-14: We create some decimal variables. We then initialize them using the
Decimal.MinusOnefield as a value. - Lines 17-19: We print the results.