Created
October 13, 2017 16:07
-
-
Save hunty/ba2cc59884790672965674189f3c34db to your computer and use it in GitHub Desktop.
Генерация массива рандомных строковых символов заданной величины
This file contains 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
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