using System;
class Program {
static void Main() {
const int length = 8;
const int minLength = 6;
const int maxLength = 18;
for (var i = 0; i < length; ++i) {
var rsl = RandomStringLatin(minLength, maxLength);
Console.WriteLine(rsl);
}
Console.WriteLine();
for (var i = 0; i < length; ++i) {
var rsс = RandomStringCirillic(minLength, maxLength);
Console.WriteLine(rsс);
}
Console.ReadKey();
}
static string RandomStringLatin(int minLength, int maxLength) {
var rand = new Random();
var length = rand.Next(minLength, maxLength + 1);
var randomString = "";
for (var i = 0; i < length; ++i) {
var reg = rand.Next(0, 2);
randomString += reg != 0
? (char)rand.Next('A', 'Z' + 1)
: (char)rand.Next('a', 'z' + 1);
}
return randomString;
}
static string RandomStringCirillic(int minLength, int maxLength) {
var rand = new Random();
var length = rand.Next(minLength, maxLength + 1);
var randomString = "";
for (var i = 0; i < length; ++i) {
var reg = rand.Next(0, 2);
randomString += reg != 0
? (char)rand.Next('А', 'Я' + 1)
: (char)rand.Next('а', 'я' + 1);
}
return randomString;
}
}
using System;
class Program
{
static void Main()
{
Random random = new Random();
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
int length = 10; // Set the desired length of the random string
// Generate a random string
char[] randomString = new char[length];
for (int i = 0; i < length; i++)
{
randomString[i] = chars[random.Next(chars.Length)];
}
// Convert the character array to a string
string randomStringResult = new string(randomString);
// Display the random string
Console.WriteLine("Random string: " + randomStringResult);
}
}