Problema Juego Cartas WPF C# (Eanglish Version)

May 16 2012 12:55 PM

i am noob handling C#, I'm making a card game (Deck Spanish) and I give you very much thenks if you could help my , my problem is this: I have a class called Card and its have tha properties Valor (string) and Palo (string) and another class called Game with a List (list <Catra>) called Deck so I fill de list Deck by     FillDeck() method with 44 positions then in the form I want to create a control Image and send call there some pictures of the cards contained within the list Deck of this way:

Game game = new Game();

for (int i = 0; i < 44; i++)
{
Image img = new Image() { Height = 150, Width = 100, Stretch = Stretch.Fill };
img.Source = new BitmapImage(new Uri(@"/Imagenes/BarajaEspaƱola/" + game.Deck[i].Valor+game.Deck[i].Palo+".gif",UriKend.Relative));     
Canvas.SetLeft(img, 450 + (i + .05));
Canvas.SetTop(img, 270 - (i + .05));
Canvas1.Children.Add(img);
}

but I get a ArgumentOutOfRangeExeption tells me: Index was out of range. Must be non-negative and less than the size of the collection.
in this line: img.Source = new BitmapImage(new Uri(@"/Imagenes/BarajaEspaƱola/" + game.Deck[i].Valor+game.Deck[i].Palo+".gif",UriKend.Relative));

(some words can be incorrects sorry).


Answers (1)