Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best data type to use for money in C#?

Tags:

c#

types

currency

What is the best data type to use for money in C#?

like image 493
NotDan Avatar asked Mar 28 '09 19:03

NotDan


1 Answers

As it is described at decimal as:

The decimal keyword indicates a 128-bit data type. Compared to floating-point types, the decimal type has more precision and a smaller range, which makes it appropriate for financial and monetary calculations.

You can use a decimal as follows:

decimal myMoney = 300.5m; 
like image 83
Lee Treveil Avatar answered Oct 13 '22 08:10

Lee Treveil