Way to increment a character in C#


Firstly, set a character−

char ch = 'K';

Now simply increment it like this −

ch++;

If you will print the character now, it would be the next character as shown in the following example −

Example

 Live Demo

using System;
using System.Collections.Generic;

class Demo {
   static void Main() {
      char ch = 'K';

      Console.WriteLine("Initial character:"+ch);

      // increment character
      ch++;
      Console.WriteLine("New character:"+ch);
   }
}

Output

Initial character:K
New character:L

Updated on: 20-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements