Hi,
How can I pick a random Alphabet Characters?
Get Random Alphabets character
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 19, 2014, 5:08 AM EDT
using System;
class Test
{
static Random r = new Random();
static void Main()
{
// generate 10 random letters
for(int i = 0; i < 10; i++)
{
char c = GetRandomChar();
Console.Write(c);
}
Console.ReadKey();
}
static char GetRandomChar()
{
int c = r.Next(26);
return (char)(97 + c);
}
}
Abhay ShankerRank #375 · 6.7K reputationPosted Mar 19, 2014, 5:23 AM EDT
using System;
static class RandomLetter
{
static Random _random = new Random();
public static char GetLetter()
{
int num = _random.Next(0, 26); // Zero to 25
char let = (char)('a' + num);
return let;
}
}
class Program
{
static void Main()
{
// Get random lowercase letters.
Console.WriteLine(RandomLetter.GetLetter());
}
}