ReadLine() 메서드는 C#의 콘솔에서 한 줄을 읽는 데 사용됩니다.
str = Console.ReadLine();
위는 변수 str에 라인을 설정합니다.
예시
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string str;
// use ReadLine() to read the entered line
str = Console.ReadLine();
// display the line
Console.WriteLine("Input = {0}", str);
}
} 출력
Input =
위에서 Console.ReadLine() 메서드를 사용하여 한 줄을 표시했습니다. 문자열은 사용자가 명령줄에서 입력합니다.