Computer >> Computer tutorials >  >> Programming >> C#

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

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