哪种数据类型最适合在C#中存储货币格式b? [英] What data type would be best for storing the money formatb of data in C#?

查看:325
本文介绍了哪种数据类型最适合在C#中存储货币格式b?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在一个应该处理用户银行交易的网站上工作.因为它将要更大规模地处理钱.我想知道什么是最适合用C#语言存储货币值的数据类型,这样才能获得最大的内存利用率和性能.

谢谢,
John

Hi,
I am working on a website which is supposed to deal with users bank transactions. As it is going to deal with money on a higher scale. I want to know what will be the best fit data type for storing the money values in C# language such that the maximum memory utilization and performance can be get.

Thanks,
John

推荐答案

十进制.如果您需要担心用于存储数字的内存量,则应该购买一台新计算机. RAM是您最少要担心的问题.
Decimal. If you have to worry about how much memory you have for storing numbers, you should buy a new computer. RAM is the least of your concerns.


是的!正如Christian Graus Decimal所建议的那样,您需要的是数据类型.您可以使用money数据类型(如果使用SQL Server)将其存储在数据库中.
yes!! as suggested by Christian Graus Decimal is the Datatype you need. You can use money datatype(if using SQL Server) for storing it in database.


您可以同时使用doubledecimal,但是十进制相对于double而言具有一些优势.

与十进制相比,double可以在更小的内存量中存储很大范围的数字,但舍入误差较小.

decimal值占用更多的内存空间(98位),但没有任何舍入错误.
You can use double and decimal both, but decimal has some advantages over double.

A double can store a great big range of numbers in a smaller amount of memory compare to decimal but are subject to small rounding errors.

A decimal value takes up more space in memory (98 bits) but does not have any rounding error.


这篇关于哪种数据类型最适合在C#中存储货币格式b?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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