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); } }
Leave a Reply