Oct 15, 2007

How to select a random value from an array

// Initialize the string array
string[] strStrings = { "Random string", "Another random value from the array", "Randomly selected index" };
// Choose a random slogan
Random RandString = new Random();
// Display the random slogan
txtRandom.Text = strStrings[RandString.Next(0, strStrings.Length-1)];