Skip to content

Instantly share code, notes, and snippets.

@camt
Created January 31, 2012 00:15
Show Gist options
  • Save camt/1707732 to your computer and use it in GitHub Desktop.
Save camt/1707732 to your computer and use it in GitHub Desktop.
simple random alpha char string variable in C#
private const int _length = 15;
private static string RandomAlphaString {
get {
var ret = "";
var random = new Random();
while (ret.Length < _length)
if (random.Next(1, 9) % 2 == 0)
ret = ret + Convert.ToChar(random.Next(65, 90));
else
ret = ret + Convert.ToChar(random.Next(97, 122));
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment