Random string generation in C#.Net
private string RandomString(int size, bool lowerCase){
StringBuilder builder = new StringBuilder();
Random random = new Random();
char ch ;
for(int i=0; i
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
builder.Append(ch);
}
if(lowerCase)
return builder.ToString().ToLower();
return builder.ToString();
}
No comments:
Post a Comment