public Player(string name, List<Card> cards)
{
this.name = name;
try
{
this.stack.insertCards(cards);//Here is the NullReferenceExeption
}
catch (Exception e)
{
throw e;
}
}
public void insertCards(List<Card> cards)
{
stack.AddRange(cards);
}
public List<Card> GetSevenCards() //the Player gets the Cards from this function
{
List<Card> list = new List<Card>();
int ran;
Random r = new Random();
for (int i = 0; i < 7; i++)
{
ran = r.Next(0, stack.Count()-1);
list.Add(stack[ran]);
stack.RemoveAt(ran);
}
return list;
}
堆得到的7卡cardlist的實例對象引用未設置到對象
凡定義'stack'? – SwDevMan81 2010-10-07 19:30:22
請發佈簡短但完整的*程序來證明問題;否則我們只是在猜測。見http://tinyurl.com/so-hints – 2010-10-07 19:32:01