What is the Decimal.One field in C#?

Overview

Decimal.One is a decimal field in C#. It represents 1.

Syntax

public static readonly decimal One;
Syntax for Decimal.One field

Parameters

This field does not take any parameters, and is only invoked on decimal.

Return value

The returned value is 1.

Code example

// Use the System
using System;
// Create the class
class HelloWorld
{
static void Main()
{
// Print the field
Console.WriteLine(Decimal.One);
// Create the decimal values
decimal decimalNumberOne = Decimal.One;
decimal decimalNumberTwo = 3.4m - Decimal.One;
decimal decimalNumberThree = 10.00m / Decimal.One;
// Print the values
Console.WriteLine(decimalNumberOne);
Console.WriteLine(decimalNumberTwo);
Console.WriteLine(decimalNumberThree);
}
}

Explanation

  • Line 9: We print the value of the fieldDecimal.One.
  • Lines 12 to 14: We create some decimal variables. We then initialize them using Decimal.One field as a value.
  • Lines 17 to 19: We print the results.

Free Resources