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

前端 未结 3 1284
天涯浪人
天涯浪人 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 18:05

    In this line here:

    z = (xy)(.8 * 1.732050808m);

    you specify .8 as a literal, but without the 'm' suffix, the literal specifies a double.

    z = (xy)(.8m * 1.732050808m);

    will fix it.

提交回复
热议问题