What is the best data type to use for money in c#?
The Decimal value type represents decimal numbers ranging from positive 79,228,162,514,264,337,593,543,950,335 to negative 79,228,162,514,264,337,593,543,950,335. The Decimal value type is appropriate for financial calculations requiring large numbers of significant integral and fractional digits and no round-off errors. The Decimal type does not eliminate the need for rounding. Rather, it minimizes errors due to rounding.
Decimal. If you choose double you're leaving yourself open to rounding errors
decimal has a smaller range, but greater precision - so you don't lose all those pennies over time!
Full details here:
Use the Money design patterns from Patterns of Enterprise Application Architecture; specify amount as decimal and the currency as an enum.
Create your own class. This seems odd, but a .Net type is inadequate to cover different currencies.
Agree with the Money pattern: Handling currencies is just too cumbersome when you use decimals.
If you create a Currency-class, you can then put all the logic relating to money there, including a correct ToString()-method, more control of parsing values and better control of divisions.
Also, with a Currency class, there is no chance of unintentionally mixing money up with other data.
Always decimal ... please decimal.. believe me.. always. sincere recommendation..regards.andy