如何在 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

更新日期:2020-06-20

2K+ 瀏覽次數

啟動你的 職業

完成課程認證

開始
廣告
© . All rights reserved.