C#运算符"/"不能应用于类型“方法组"和“整数"的操作数 [英] C# Operator '/' cannot be applied to operands of type 'method group' and 'int

查看:441
本文介绍了C#运算符"/"不能应用于类型“方法组"和“整数"的操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此行发生错误:

xPoint是Int32

xPoint is Int32

随机大小为整数

xPoint = pictureBox1.Width / 2 - randomsize -  objectPos.getOffset / 10 * randomsize / 192;         

显然是导致此问题的函数,有人可以解释一下为什么吗?

Here's the function(s) which apparently cause it, can someone explain me why?

        public float getSector()
        {
            return (float)Math.Floor(x / 192 + 135);
        }

        public Int32 getOffset ()
        {
            return (Int32)((x / 192) - getSector() + 135) * 192 * 10;
        }

推荐答案

getOffset方法,必须调用.

objectPos.getOffset() / 10

(请注意getOffset之后的括号)

在没有括号的情况下,您指的是函数,而不是函数的值.

Without the parens, you are referring to the function, not its value.

如果要将getOffset用作属性,则需要输入getset关键字.

If you intend for getOffset to be a property, you need to put in the get and set keywords.

这篇关于C#运算符"/"不能应用于类型“方法组"和“整数"的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆