Phương thức Console.ReadLine () trong C # được sử dụng để đọc dòng ký tự tiếp theo từ luồng đầu vào chuẩn.
Cú pháp
Cú pháp như sau -
public static string ReadLine ();
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức Console.ReadLine () trong C # -
using System;
public class Demo{
public static void Main(){
string str;
Console.WriteLine("Enter any subject...");
str = Console.ReadLine();
Console.WriteLine("Entered subject = "+str);
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
Enter any subject... Entered subject = Maths