C# Program to generate random lowercase letter


Firstly, set Random class −

Random random = new Random();

Set a range under the Next() method. This displays a letter between 0 and 26.

int a = random.Next(0, 26);

Here is the complete code −

Example

 Live Demo

using System;
using System.IO;
using System.Linq;
class Demo {
   static void Main() {
      Random random = new Random();
      // random lowercase letter
      int a = random.Next(0, 26);
      char ch = (char)('a' + a);
      Console.WriteLine(ch);
   }
}

Output

t

Updated on: 22-Jun-2020

991 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements