What is the purpose of Decimal.One, Decimal.Zero, Decimal.MinusOne in .Net

后端 未结 4 908
谎友^
谎友^ 2021-02-01 11:58

Simple question - why does the Decimal type define these constants? Why bother?

I\'m looking for a reason why this is defined by the language, not possible uses or effec

4条回答
  •  無奈伤痛
    2021-02-01 12:32

    Some .NET languages do not support decimal literals, and it is more convenient (and faster) in these cases to write Decimal.ONE instead of new Decimal(1).

    Java's BigInteger class has ZERO and ONE as well, for the same reason.

提交回复
热议问题