Created
January 31, 2012 00:15
-
-
Save camt/1707732 to your computer and use it in GitHub Desktop.
simple random alpha char string variable in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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