Generate a random stream of lowercase letters with the Random Next method.
Random lowercase letter. A random lowercase letter is needed. It must be between "a" and "z" inclusive. We use the C# programming language. We generate random characters by providing inclusive and exclusive bounds to the Random variable.
Example. This program introduces two classes to the compilation unit. The RandomLetter class is a static class, meaning it cannot be instantiated. The Program class contains the Main entry point.Static
GetLetter: This static method on the RandomLetter type provides a way to get the next random letter.
Info: The GetLetter method provides a way to get another random letter. It internally references the static field Random variable.
C# program that random lowercase letter
static class RandomLetter
static Random _random = new Random();
public static char GetLetter()
// This method returns a random lowercase letter.
// ... Between 'a' and 'z' inclusize.
int num = _random.Next(0, 26); // Zero to 25
char let = (char)('a' + num);
static void Main()
// Get random lowercase letters.
Random fields. When using the Random variable type, it is often useful to store the Random variable itself as a static field. This is because, logically, Random implements a stream of randomness, not true randomness.
Summary. We examined a program that implements a random letter generation routine. The method shown returns a random letter between "a" and "z" in char representation. It can be called sequentially as it is implemented as a random stream.
Note: The static modifier is used here to simplify the program layout and reduce instantiations.