If we declare padding as const decimal, the padding is not working.
mymoney = 1.2 and your money = 1.20, how can this behavior be explained?
class Program
{
static void Main(string[] args)
{
decimal balance = 1.2m;
const decimal ConstPadding = 0.00m;
decimal padding = 0.00m;
decimal mymoney = decimal.Round(balance + ConstPadding, 2);
decimal yourmoney = decimal.Round(balance + padding, 2);
Console.WriteLine(mymoney); // 1.2
Console.WriteLine(yourmoney); //1.20
}
}
As an accompaniment to Jon’s answer, below is the IL produced from your code. As he mentioned, mymoney was never added.
To produce the IL (i.e. if you want to look under the hood in the future), just run ILDASM from a VS command prompt, then load your executable and double-click on the method that you would like to look at.