我創建一個字典,然後用main()中的條目填充它,然後調用使用上述字典的方法。在傳遞給此方法的參數中沒有包含字典,我怎樣才能訪問它而不會出現錯誤'非靜態字段,方法或屬性'XXX.YYY.dict'需要對象引用?從C#中主要的方法訪問字典#
編輯:這裏是代碼請求:
public static void Main()
{
ulong board = AS | KH | FD | FC | TH | SH | NC;
Dictionary<ulong, int> dict; dict = new Dictionary<ulong, int>();
for (int a = 0; a < 49344; a++)
{
dict.Add(helloworld.Table.handhashes[a], helloworld.Table.ratings[a]);
}
int hand = 0;
for (int ai1 = 0; ai1 < 100000000; ai1++)
{
hand = FCheck(board);
}
}
錯誤發生在F確認,下面一行:
FCheck = dict(condensedBoard);
能否請您包括您要使用的代碼? – 2010-10-25 13:22:22
你可能會在這裏發佈你的代碼......聽起來像是一個非常基本的問題。讀一本書可能也有幫助。 – 2010-10-25 13:23:53
更多的信息不會錯過這裏,以及Ryan Berger所建議的代碼。 – jimplode 2010-10-25 13:24:32