How to get random element from integer array in c#.net
Now for generating random element from the array first you have to generate the random number and using this random number you can get the random element form the array.
Random rnd = new Random();
int b = rnd.Next(0,5);
//show the random element in text box
textBox1.Text = a[b].ToString();
For Generating Random rows from dataset here
Code : -
// array of integer
int[] a={10,20,30,40,50,60,70,80,90};Random rnd = new Random();
int b = rnd.Next(0,5);
//show the random element in text box
textBox1.Text = a[b].ToString();
For Generating Random rows from dataset here
Comments
Post a Comment