如何在 C# 中列印多行空行?


為了顯示多行空行,我們將採用一個 while 迴圈。

這裡,我們使用 Console.WriteLine(); 列印 10 行空行。

while (a < 10) {
   Console.WriteLine(" ");
   a++;
}

以下是顯示多行空行的完整程式碼 −

示例

using System;
namespace Program {
   public class Demo {
      public static void Main(String[] args) {
         int a = 0;
         while (a < 10) {
            Console.WriteLine(" ");
            a++;
         }
         Console.WriteLine("Displayed 10 blank lines above!
");          Console.ReadLine();       }    } }

更新於:2020 年 6 月 22 日

673 次瀏覽

開啟你的 職業 生涯

透過完成課程來獲得認證

開始
廣告
© . All rights reserved.