I'm looking to multiply a value in the set
backing field in C# (for an ASP.NET MVC application). I'm doing this to avoid issues with dividing floating point numbers and therefore the properties are integers that require to be multiplied and divided for the sake of appearance and then stored as decimals.
Following the answer here, I'm trying to use the backing fields to complete these operation on a property like so:
public decimal SomeDecimal
{
get
{
return this.SomeDecimal / 100;
}
set
{
this.SomeDecimal = this.SomeDecimal * 100;
}
}
I'm getting the following warning:
Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Could anyone explain the proper way to multiply and divide the number without doing so in the view / controller.