DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Build A Random String
/// <summary>
/// Build a random string (for id, login, password...)
/// </summary>
public static string randomString() {
int length = new Random().Next(6, 10);
return randomString(length);
}
/// <summary>
/// Build a random string (for id, login, password...)
/// </summary>
public static string randomString(int length) {
string tempString = Guid.NewGuid().ToString().ToLower();
tempString = tempString.Replace("-", "");
while (tempString.Length < length) {
tempString += tempString;
}
tempString = tempString.Substring(0, length);
return tempString;
}




