I have 5 separate image lists that all need to pull 5 values different from each other. I have been trying several different ways but haven't found one that works. The program is supposed to be a poker hand so they all need to be different cards.
This is what I have. (deleted some due to not working). What do I need to do to achieve these 5 different cards?
namespace Random_Card
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void getCardButton_Click(object sender, EventArgs e)
{
Random rand = new Random();
int index = rand.Next(cardImageList.Images.Count);
int index1 = rand.Next(cardImageList.Images.Count);
int index2 = rand.Next(cardImageList.Images.Count);
int index3 = rand.Next(cardImageList.Images.Count);
int index4 = rand.Next(cardImageList.Images.Count);
cardPictureBox.Image = cardImageList.Images[index];
cardPictureBox1.Image = cardImageList.Images[index1];
cardPictureBox2.Image = cardImageList.Images[index2];
cardPictureBox3.Image = cardImageList.Images[index3];
cardPictureBox4.Image = cardImageList.Images[index4];
while (index == index1)
{
new Random();
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire