How to use Rand()

Ask general questions here.
Posts: 1
Joined: Mon Nov 02, 2009 3:14 am

How to use Rand()

Post by mpolyakov » Mon Nov 02, 2009 3:46 am

How to use Random function (C#) when you need to select random item from two dimensional array?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: How to use Rand()

Post by Support Team » Mon Nov 02, 2009 9:38 am

That`s quite easy. Generate a random number between your array range in the 2 dimensions

// 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,
Ranorex Supoort Team