对于.NET货币数据类型? [英] Money data type for .NET?

查看:178
本文介绍了对于.NET货币数据类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一个良好的理财数据,支持类型作为.NET 货币汇率(与相关的行为和放大器;操作)。

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

  • 注:我开始寻找源$ C ​​$ C书中的测试驱动开发用实例按作者肯特·贝克 - 他开发了一个很好的金融概念。无法找到完整的源代码在网上。这本书不包含一个单一上市 - 而不是它的发展源$ C ​​$ c在这本书的时间
  • Note: I started searching for the source code seen in print in the book Test-Driven Development By Example by author Kent Beck - he develops a nice Monetary concept. Unable to find the complete source online. The book does not contain one singular listing - instead it develops the source code over the duration of the book.

虽然本书没有深究下去我也想Money类,以支持不同的四舍五入机制,因为这也各不相同世界各地的金融机构之一。

Although the book doesn't go deeper I would also like the Money class to support different rounding mechanisms because that also varies among financial institutions around the globe.

修改1: 澄清

通过钱班我的意思是,我可以用它来支持资金及其操作,完成与货币支持和汇率计算,一个.NET数据类型。类似的东西是一种更高层次的抽象,可能在内部使用基本数据类型。此外,它可能依赖的类捆绑想:金钱,ExchangeRate,银行等

By "Money class" I mean a .NET data type that I can use to support money and its operations, complete with currency support and exchange rate calculations. Something like that is a higher level abstraction and might internally use a primitive data type. Also it might rely on a bundle of classes like: Money, ExchangeRate, Bank, etc.

这可能是值类型(即结构)或引用类型(即类),但无论哪种方式,这将是完整的,并支持上述功能。

It might be a value type (i.e. struct) or reference type (i.e. class) but either way it would be complete and support the aforementioned features.

(这也说明了为什么原始小数,整数或其他原始类型将不足以对所有的钱需要)

(This also shows why a raw decimal, int or other primitive type won't suffice for all Money needs)

一个货币数据类型的目标将是:

Objectives of a Money data type would be:

  • 安全功能(如prevent算法在不同的货币类型)。
  • 店铺的值(即澳元,美国,DKK)的货币类型。
  • 存储格式的信息(即十进制分组,货币符号等)。
  • 在转换供应商(如汇率)来帮助完善了该解决方案。
  • 在减少多种货币在离pression实现的结果。

注意:像汇率变化的数据值可从外部源加载和使用。这个问题不能由此推断什么动态是硬coded到钱的概念。

Note: Varying data values like exchange rates can be loaded from an external source and used. This question does not infer anything dynamic is hard-coded into the concept of Money.

推荐答案

Martin Fowler的认为金钱作为量的一个特例,其次,他认为金钱正确的数据类型应该是大整数。而且他确实有他的道理。

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.

数量和货币格局由Martin Fowler的

这篇关于对于.NET货币数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆