Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Random random = new Random();
- int randomNumber = random.Next(1, listBox1.Items.Count);
- listBox1.Select();
- listBox1.SelectedItem = listBox1.Items[randomNumber];
- var str = listBox1.SelectedItem;
- // MessageBox.Show(str.ToString());
- //or
- string bass = str.ToString();
- //SOURCE: https://stackoverflow.com/questions/11771050/how-do-i-get-a-random-item-from-a-listbox-then-compare-it-in-c
- //Answered by Habib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement