这是我正在制作的简单纸牌游戏的脚本摘录。但我对数组不是很好,因为某些原因我不能让它工作。它不断回复
无法将方法组'Draw'转换为非委托类型'int'。
我环顾四周但似乎无法找到答案。如果您需要上下文的其余代码,我可以发布它。
// Generates three cards with two random values on each then
stores them inside the usercardvalues array
int[] UserCardValues = new int[3] {PlayDeck.Draw, PlayDeck.Draw, PlayDeck.Draw};
Console.WriteLine(UserName + "'s Damage / Health values are");
Console.WriteLine("Card 1: {0}", UserCardValues[0]);
Console.WriteLine("Card 2: {0}", UserCardValues[1]);
Console.WriteLine("Card 3: {0}", UserCardValues[2]);
Console.WriteLine();
Console.WriteLine("Hit enter to continue!");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.ReadLine();
// Gets and prints the dealers card from the random generator
int[] DealerCardValues = new int[3] {PlayDeck.Draw, PlayDeck.Draw, PlayDeck.Draw};
Console.WriteLine("The Dealers Damage / Health Values are");
Console.WriteLine("Card 1: {0}", DealerCardValues[0]);
Console.WriteLine("Card 2: {0}", DealerCardValues[1]);
Console.WriteLine("Card 3: {0}", DealerCardValues[2]);
Console.WriteLine();
Console.WriteLine("Hit enter to continue!");
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~");
Console.ReadLine();
答案 0 :(得分:4)
由于Draw
是一种方法,并且错误很明显,所以你应该像方法一样使用它
PlayDeck.Draw()
而不喜欢:
PlayDeck.Draw
但记得,Draw()
需要return
和int
。