not all code paths return a value

前端 未结 1 1504
盖世英雄少女心
盖世英雄少女心 2020-12-06 21:56

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)         


        
相关标签:
1条回答
  • 2020-12-06 22:10

    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/...

    0 讨论(0)
提交回复
热议问题