Both work, what happens is that one is assigned, the other is not.
When doing:
Math.Round(...); // Donde los puntos son tu expresion aritmetica o valor.
You are not assigning the return value of Math.Round(...)
, you only make the operation and nothing else happens afterwards.
But when doing:
decimal t = Math.Round(...); // Lo mismo con los puntos...
Console.WriteLine(t); // Debe de darte el round del valor.
You are assigning the result of the function Math.Round
in variable t
(In my case) .
Functions have a return value, that value is assignable to a variable or used in an expression, example:
int dos() {
return 2; // Devuelve 2 a quien me llame.
}
If I do:
decimal MiDecimal = Math.Round((dos() * 8.25) + 0.05, 1);
That is summarized to:
decimal MiDecimal = Math.Round((2 * 8.25) + 0.05, 1);
And carry out the operation, where 16.5
is the value of MiDecimal
.