What is the best data type for Currency in C#?


This content was proof-read by Grammarly. You can Try Grammary for FREE

If you are looking at finding out what could be the best data type for currency in C# ?, this post will provide a quick tip or insights on the same.

What is the best data type for Currency in C#?

Use decimal for any currency or money values.

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.

Here’s a sample code snippet demonstrating how to use decimal.

public class Hello {
    public static void Main() {
        decimal salary = 75000.50M;
        System.Console.WriteLine("Salary : "  + salary);
    }
}
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: