Breaking News
Loading...
Wednesday 24 July 2013

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.

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 

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer