Page 1 of 1

How to use Rand()

Posted: Mon Nov 02, 2009 3:46 am
by mpolyakov
How to use Random function (C#) when you need to select random item from two dimensional array?

Re: How to use Rand()

Posted: Mon Nov 02, 2009 9:38 am
by Support Team
That`s quite easy. Generate a random number between your array range in the 2 dimensions

.e.g.
// for Array[100][80]
Random random = new Random();
int xPos = random.Next(100);
int yPos = random.Next(80);
and take the array content from your random position.

Best regards,
christian
Ranorex Supoort Team