Pages

Sunday, March 17, 2013

C#: Display Random String

public void RandomString()
{
 string[] randStr = new string[5]{"hi","hello","how","are","you"};
 int indexStr = rnd.Next(randStr.Length);
 Console.WriteLine(randStr[indexStr]);
}

Output: hello

No comments:

Post a Comment