You are mixing
double
(
dis
) and
decimal
(
Total
) in your calculation so you are getting an error
Quote:
Operator '*' cannot be applied to operands of type 'decimal' and 'double'
This is because
0.05
is of type
double
. To convert it to decimal add an 'M' to the end of it like this
dis = Total - (Total * 0.05M);
However you are still mixing
double
and
decimal
values and will then get a different error
Quote:
Cannot implicitly convert type 'decimal' to 'double'. An explicit conversion exists (are you missing a cast?)
To get around that cast the result of the calculation to a double
dis = (double)(Total - (Total * 0.05M));
or better yet, be consistent with your variable types