有没有理由C#System.Decimal记得它输入的尾随零的数量?请参阅以下示例:
public void DoSomething()
{
decimal dec1 = 0.5M;
decimal dec2 = 0.50M;
Console.WriteLine(dec1); //Output: 0.5
Console.WriteLine(dec2); //Output: 0.50
Console.WriteLine(dec1 == dec2); //Output: True
}
Run Code Online (Sandbox Code Playgroud)
小数被归类为相等,但是dec2会记住它是以额外的零输入的.这是什么原因/目的?