Error 1 Operator '*' cannot be applied to operands of type 'method group' and 'double'

前端 未结 5 1781
难免孤独
难免孤独 2021-01-25 19:11

I believe what i am trying to do is very simple but I get the error. Operator \'*\' cannot be applied to operands of type \'method group\' and \'double\'

I want to mult

5条回答
  •  隐瞒了意图╮
    2021-01-25 19:26

    In c# a methodcall is always denoted by a pair of braces, while the method itself is addressed by it's name. So dayrental() is the returnvalue of dayrental, while dayrental is the method dayrental. Therefore you are multiplying the method dayrental with the with 19.95 which obviously fails. What you are trying to do is:

    rental = dayrental() * 19.95;
    

    Also dayrental returns void so youm ight want to change it to

     public double dayrental()
    

    and return some value.

提交回复
热议问题