現在我真的很困惑。在類和表之間傳遞int值
我有持有大陣
int[,] map = new int[1000, 1000];
我也得到了含法「畫」一類的一個WinForm。 繪製方法現在需要獲取表單中數組中位置的值。我試着做以下事情:
在我的Form類,我添加
public int mapContentAtXY(Point mapPosition)
{
return map[mapPosition.X, mapPosition.Y];
}
現在,如果我嘗試執行
myInt = Ingame.mapContentAtXY(myPoint);
//Note: Ingame is the name of my Form
它說
Error 2 'Neu.Ingame' does not contain a definition for 'mapAtPositionXY'
這是真的令人困惑的是,我剛剛添加了這個定義,它也被設置爲公開。那麼,爲什麼它不起作用?
它需要一個'InGame'的實例,你試圖從類定義中調用它(靜態地) – Sayse
'mapAtPositionXY'或'mapContentAtXY'? – paul
'Ingame.mapContentAtXY(myPoint)' - >'this.mapContentAtXY(myPoint)' –