ในการแสดงบรรทัด Console.Write() ถูกใช้ในภาษา C#
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