Home c# Select multiple random values ​​from the data array in the form of...

Select multiple random values ​​from the data array in the form of pictures

Author

Date

Category

Please tell me the newcomer, you need to select several random values ​​from the data array and output them as pictures

How to bind to each value in an array or image dictionary and then bring to “Pickerboxes”?

That’s how it turned out to display a random picture by pressing the button.

string [] food = new string [] {"donut", "bread", "water"};
String Randomfood = Food [New Random (). Next (0, Champ.Length)];
TextBox2.Text = Randomfood;
if (randomchamp == "donut")
{
  pictureBox2.image = properties.resources.donut_0;
}
if (randomchamp == "Bread")
{
  pictureBox2.image = properties.resources.bread_0;
}
if (randomchamp == "Water")
{
  pictureBox2.image = properties.resources.water_0;

Answer 1

You will need to call your pictures in the resources exactly as they are named in the array of keys Food

string [] food = new string [] {"donut", "bread", "water"};
String Randomfood = Food [New Random (). Next (0, Champ.Length)];
PictureBox2.image = (Bitmap) properties.resources.resourcemanager.getObject (Randomfood)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions