Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

วิธีพิมพ์ข้อความบน Console ใน C#

ใช้ Console.WriteLine() แสดงข้อความ

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