Money data type for .NET?

后端 未结 8 1028
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:43

    Have a look here:

    http://blogs.msdn.com/lucabol/archive/2008/12/04/financial-functions-for-net-released.aspx

    It provides a .NET library replicating all the excel financial functions.

    Doing currency conversion is tricky, because obviously it changes continously, so hardcoded values will be more or less useless. However, you may be able to use a web service to access up-to-date exchange rates. This one looks like a good start. Even better, a REST-style interface to the same converter:

    http://www.webservicex.com/CurrencyConvertor.asmx/ConversionRate?FromCurrency=GBP&ToCurrency=EUR
    

    So that outputs the conversion rate of pounds sterling to euros.

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

    I am the author of NMoneys which I think it might come handly. It has not been "officially released" yet, but it will change very little until it does.

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

    Money Data Type @ The Code Project

    http://www.codeproject.com/KB/vb/moneyDatatype.aspx

    Author states similar problem:

    as part of a recent application I realized how lacking .NET is for currency support, don't get me wrong, there are many "pieces" but the glue for all items is missing, so this article is a response to that.

    and fulfills objectives

    my main objectives became

    • Store the currency type with the value (i.e. AUD, US, DKK).
    • Store formatting details (i.e. decimal grouping, currency symbols, etc.).
    • Conversion providers, I didn't want to hard code this as it is a datatype and not a solution.
    • Development safety features (i.e. prevent arithmetic on different currency types).

    So far this the closest .NET code to what I'm searching for. It fulfills most requirements of Money.

    If anybody has something better it would be much appreciated.

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

    Martin Fowler considers money as a special case of "Quantity", secondly he thinks the right Data Type for money should be the Big Integer. And he does have a point.

    Quantity and Money Pattern by Martin Fowler

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

    NodaMoney provides a library that treats Money as a first class citizen in .NET and handles all the ugly bits like currencies and formatting.

    It complies with the currencies in ISO 4217. And it's the .NET counterpart of the java library JodaMoney.

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

    you will probably find that creating your own class will result in the best solution.

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