Interesting behaviour of type “decimal” in C#

前端 未结 5 1009
遇见更好的自我
遇见更好的自我 2021-02-12 13:34

If we declare padding as const decimal, the padding is not working.

mymoney = 1.2 and your money = 1.20, how can this behavior be explained?

class Progra         


        
5条回答
  •  不思量自难忘°
    2021-02-12 14:00

    The sum operation with the constant padding is getting completely excluded from the MSIL, yet it is there for a non-constant field. I was not able to find any references to FCallAddSub function, unfortunately, but that's the one who "optimizes" the call.

提交回复
热议问题