I have a C# method and which accepts three string
parameters. After converting them to decimal
, I am trying to perform a simple math calculation. I don't understand, why isn't the result correct?
decimal d = MyFunction(x, y, z);
public decimal MyFunction(string x, string y, string z)
{
decimal dx = 0;
decimal dy = 0;
decimal dz = 0;
Decimal.TryParse(x, out dx);
Decimal.TryParse(y, out dy);
Decimal.TryParse(z, out dz);
decimal result = dx - dz + dy;
return result;
}
Thanks in advance.