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;
精彩评论