Need help with generic lists in c#

will someone tell me why this one won’t work. hand and playerdeck are dcard lists.

		Dcard tempcard;
		tempcard= playerdeck [0];
	    hand.Add (tempcard);		
		playerdeck.RemoveAt (0);

I get a “NullReferenceException: Object reference not set to an instance of an object” error when I add the tempcard to the hand. any ideas?

There is not enough information here to help you. What line is giving you an exception? Can you post the playerdeck code? Where is hand created?

If I had to guess, it would be that playerdeck or hand has not been created anywhere, i.e. you just have something like this:

List<Dcard> hand;

you need to instantiate hand:

List<Dcard> hand = new List<Dcard>();