C#, Operator '*' cannot be applied to operands of type 'double' and 'decimal'

前端 未结 3 1287
天涯浪人
天涯浪人 2020-12-06 17:19

This error should be a simple one but I cant seem to make it work. The problem lies in the fact that this very same code works earlier in the program. I don\'s see any reaso

3条回答
  •  庸人自扰
    2020-12-06 17:52

    You didn't say which line it was, but I'm betting on these two:

    z = (x*y)*(.8 * 1.732050808m);
    

    And:

    z = (1000 * x)/(y * 1.732050808m)* .8;
    

    Note that your .8 does not have the 'm' qualifier. Every other place I see you did supply that.

提交回复
热议问题