Skip to content

Instantly share code, notes, and snippets.

@hunty
Created October 13, 2017 16:07
Show Gist options
  • Save hunty/ba2cc59884790672965674189f3c34db to your computer and use it in GitHub Desktop.
Save hunty/ba2cc59884790672965674189f3c34db to your computer and use it in GitHub Desktop.
Генерация массива рандомных строковых символов заданной величины
public static string[] RandomStringArray(int size)
{
var result = new string[size];
Random random = new Random();
char ch;
for (int i = 0; i < size; i++)
{
//Генерируем число являющееся латинским символом в юникоде
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
//Конструируем строку со случайно сгенерированными символами
result[i] = ch.ToString();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment