Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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.
 
Share this answer
 
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.
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900