如何使用 C# 在控制檯上列印一行?
在 C# 中,要顯示一行,使用 Console.Write()。
Console 在控制檯上顯示結果。我首先設定一個字串。
string str = "Tom Hanks is an actor";
現在顯示上面的行。
Console.WriteLine(str);
以下是完整的程式碼 −
示例
using System;
namespace Program {
public class Demo {
public static void Main(String[] args) {
string str = "Tom Hanks is an actor";
Console.WriteLine("Displaying a line below");
Console.WriteLine(str);
Console.ReadLine();
}
}
}輸出
Displaying a line below Tom Hanks is an actor
廣告
資料庫結構
聯網
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP