Money data type for .NET?

后端 未结 8 1029
Happy的楠姐
Happy的楠姐 2021-01-31 02:52

Looking for a good Money data type for .NET that supports currencies and exchange rates (with related behaviour & operatio

相关标签:
8条回答
  • 2021-01-31 03:56

    If you are looking for patterns, you could check out Joda Money. It is Java, but should give you some ideas on an API. A C# implementation would be much less verbose due to operator overloading.

    0 讨论(0)
  • 2021-01-31 03:57

    I do understand your points about the benefit of having abstraction layer over money here. However, my view on money and its "operations" is quite blurry. For other things like File, it's clear to me there should be Open, Read, Write, Close operations. But for Money, I can't think of much other than basic math operations (+,-,*,/)

    One of C++ quantitative finance lib I know does contain this Money abstraction (http://quantlib.org/reference/class_quant_lib_1_1_money.html.) But you can clearly see that this is a very thin wrapper which provide basic operator overloads and unit conversion over Decimal.

    In most cases, I think decimal can fulfill your requirement. If there is specific Money operation you need to support, I think it's okay to roll out your own classes.

    0 讨论(0)
提交回复
热议问题