I come from a background in C++, and I know that you cannot accurately compare floats for equality. For C#, I simply assumed the same policy applies to decimal values, or an
Your code will work as expected. C# decimal
s are optimized to be very accurate at representing base 10 numbers, so if that's what you're comparing (money, ...), everything should be fine.
Here's a very clear explanation about the accuracy of decimals by Jon Skeet:
Difference between decimal, float and double in .NET?