Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string GenRandomString(string Alphabet, int Length)
- {
- //string Ret = "";
- Random rnd = new Random();
- StringBuilder sb = new StringBuilder(Length-1);
- int Position = 0;
- for (int i = 0; i < Length; i++)
- {
- Position = rnd.Next(0, Alphabet.Length-1);
- sb.Append(Alphabet[Position]);
- //Ret = Ret + Alphabet[Position]; //- так делать не стоит, в данном случае StringBuilder дает явный выигрыш в скорости
- }
- //return Ret;
- return sb.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement