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

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Toggle Footer