4

I got this compiler error, what is the problem?

public PictureBox getinfo(int i, int j)
{
    return grid[i, j];
}

public  PictureBox kingmove(int i, int j)///<-----the problem is here
{
    getinfo(i, j);

    if (i < 9)
    {
        grid[i, j] = grid[i - 1, j - 1];
    }
    else
    {
        grid[i, j] = grid[i, j];
    }
2
  • How about reading a good C# book? That way you don't need to ask so often on SO and delete the question afterwards... Commented Nov 27, 2010 at 14:31
  • This common error occurs when you miss a return for a function or you returning a wrong datatype compare to what function should return. Commented Nov 27, 2010 at 15:15

1 Answer 1

6

Your second method has no return statement but a return-type different from void.
Add a return statement at the end of the method and not in the beginning.

And you could have edited that into your previous question.

The way you mix UI and game-logic is ugly too. The game-logic should know nothing about WinForms, picture-boxes,...
Instead write a function which takes a gamestate and renders it into some control/bitmap/picturebox/...

Sign up to request clarification or add additional context in comments.

1 Comment

Additionally his call to getinfo() probably isn't doing anything useful, but that's an entirely different issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.