Hi all,
I'm new to C# but I'm really enjoying learning it. I've just started a little exercise to try and make a BlackJack simulator. Using 'Lists' to hold the cards etc.
My form shows the possible 5 cards that the Player can hold as Labels (PlayerCard1, PlayerCard2, PlayerCard3 etc).
I want to do something like this:
for(i = 0; i < player1.PlayerCards.Count; i++) {
PlayerCard.Text = player1.PlayerCards.ShowCard();
}
Notice the "PlayerCard" bit in the for loop.
How can I add a variable to a name so that it will loop through all my labels ?
Is it even possible??
Many thanks for any light you can shed on this.
John ;-)
Spend a few minutes remembering your loved ones,
Create a permanent memorial to commemorate their life,
I'm new to C# but I'm really enjoying learning it. I've just started a little exercise to try and make a BlackJack simulator. Using 'Lists' to hold the cards etc.
My form shows the possible 5 cards that the Player can hold as Labels (PlayerCard1, PlayerCard2, PlayerCard3 etc).
I want to do something like this:
for(i = 0; i < player1.PlayerCards.Count; i++) {
PlayerCard.Text = player1.PlayerCards.ShowCard();
}
Notice the "PlayerCard" bit in the for loop.
How can I add a variable to a name so that it will loop through all my labels ?
Is it even possible??
Many thanks for any light you can shed on this.
John ;-)
Spend a few minutes remembering your loved ones,
Create a permanent memorial to commemorate their life,