1
Answer

C# comparing user input to random image??

momo akhouri

momo akhouri

12y
1.9k
1
Hey everyone,

I've been stuck on this for a while now and I am not sure on what to do, so help would be great!

I have created an application that displays random images in a picturebox when a button is clicked. I have done this by creating an array of images, and using the random class.

I also have a textbox for user input, so that when a random image appears (flag of america), the user should be able to guess what flag it is, and type his/her answer into the textbox.

How would I make this comparison? A little guidance would be great:)

My code so far:

public void button1_Click(object sender, EventArgs e)
{


//Array of images
Image[] images = new Image[3];
images[0] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\india.png");
images[1] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\australia.png");
images[2] = Image.FromFile(@"C:\Users\Momo\Desktop\f… 1\america.png");





int number = (r.Next(0, images.Length));

pictureBox1.Image = images[number];

Thank you very much:)
Answers (1)