パブリッククラスと構造体を宣言してから、メインから関数を実行する必要があり、クラス内の変数とメインから構造体を宣言できないという問題があります。このため、「メソッドのオーバーロードなし」エラーのため、関数は機能しません。これを修正するにはどうすればよいですか?非常にシンプルなものが欠けているような気がしますが、見えません。
前もって感謝します。さらに詳しい情報が必要な場合は、遠慮なくお問い合わせください。
public struct CellReference
{
private int CNorth, CEast;
public int CellsNorth
{
get
{
return CellsNorth;
}
set
{
CNorth = value;
}
}
public int CellsEast
{
get
{
return CellsEast;
}
set
{
CEast = value;
}
}
}
static void Main(string[] args)
{
Piece black1, black2, black3, black4, black5, black6, black7, black8, black9, black10, black11, black12, white1, white2, white3, white4, white5, white6, white7, white8, white9, white10, white11, white12;
StartGame();
Console.ReadKey();
}
public class Piece
{
public CellReference Location;
public bool isBlack;
public bool isKing;
}
基本的に、StartGame()が必要とするいくつかの変数を初期化することはできません。
さてStartGamesのように:
static void StartGame(ref int CNorth, ref int CEast, ref bool isKing, ref bool isBlack, ref int CellsEast, ref int CellsNorth, ref Piece black1, ref Piece black2, ref Piece black3, ref Piece black4, ref Piece black5, ref Piece black6, ref Piece black7, ref Piece black8, ref Piece black9, ref Piece black10, ref Piece black11, ref Piece black12, ref Piece white1, ref Piece white2, ref Piece white3, ref Piece white4, ref Piece white5, ref Piece white6, ref Piece white7, ref Piece white8, ref Piece white9, ref Piece white10, ref Piece white11, ref Piece white12)
ただし、メインでStartGame()を呼び出すと、すべての参照をメインに配置していないため、参照が機能しません。