CSharp examples for System:Random
Generate Random Name
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;//w w w. j a v a 2 s . c o m public class Main{ public static string GenerateRandomName() { const string consonant = "aeiouy"; const string vowel = "bcdfghjklmnpqrstvwxz"; var name = string.Empty; var rand = new Random(); var nameLength = rand.Next(3, 10); for (var i = 0; i < nameLength; i++) { name += i % 2 == 0 ? vowel[rand.Next(vowel.Length - 1)] : consonant[rand.Next(consonant.Length - 1)]; } return name; } }