C# Program to generate random lowercase letter

CsharpProgrammingServer Side Programming

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
raja
Published on 05-Sep-2018 14:56:36
Advertisements