HiveBrain v1.2.0
Get Started
← Back to all entries
patterncsharpCritical

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

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
datamoneywhatthebestusefortype

Problem

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

Solution

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;

Code Snippets

decimal myMoney = 300.5m;

Context

Stack Overflow Q#693372, score: 524

Revisions (0)

No revisions yet.