What data type should I use to represent money in C#?

后端 未结 7 2102
醉话见心
醉话见心 2020-12-04 19:15

In C#, what data type should I use to represent monetary amounts? Decimal? Float? Double? I want to take in consideration: precision, rounding, etc.

7条回答
  •  囚心锁ツ
    2020-12-04 19:59

    Consider using the Money Type for the CLR. It is a custom value type (struct) that also supports currencies and handles rounding off issues.

提交回复
热议问题