C# 中遞增字元的方式


首先,設定一個字元

char ch = 'K';

現在只需像這樣遞增它

ch++;

如果你現在列印該字元,它將是下一個字元,如下例所示:

示例

 即時演示

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);
   }
}

輸出

Initial character:K
New character:L

更新於: 20-Jun-2020

2K+ 瀏覽量

開啟您的 職業生涯

透過完成課程,獲得認證

開始
廣告
© . All rights reserved.