简体   繁体   中英

C# Operator '/' cannot be applied to operands of type 'method group' and 'int

Error occurs on this line:

xPoint is Int32

randomsize is int

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 is a Method , and must be called.

objectPos.getOffset() / 10

(note the parens after getOffset)

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM