andrew4582

GenerateRandomString

Aug 19th, 2011
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1.         static string GenerateRandomString(int count = 10000,bool endnl = false) {
  2.             Random rand = new Random(Guid.NewGuid().ToString().GetHashCode());  
  3.             return GenerateRandomString(rand,count,endnl);
  4.         }
  5.         static string GenerateRandomString(Random rand,int count = 10000,bool endnl = false) {
  6.             StringBuilder sb = new StringBuilder(count);
  7.             for(int i = 0;i < count;i++)
  8.                 sb.Append((char)('a' + rand.Next(0,26)));
  9.             if(endnl)
  10.                 sb.AppendLine();
  11.             return sb.ToString();
  12.         }
Advertisement
Add Comment
Please, Sign In to add comment