Write() 메서드와 WriteLine() 메서드의 차이점은 줄 바꿈 문자를 기반으로 합니다.
Write() 메서드는 출력을 표시하지만 줄 바꿈 문자를 제공하지 않습니다.
WriteLine() 메서드는 출력을 표시하고 문자열 끝에 새 줄 문자를 제공합니다. 이렇게 하면 다음 출력에 대한 새 줄이 설정됩니다.
Write() 메서드와 WriteLine() 메서드의 차이점에 대해 알아보기 위해 예제를 살펴보겠습니다. -
예시
using System;
class Program {
static void Main() {
Console.Write("One");
Console.Write("Two");
// this will set a new line for the next output
Console.WriteLine("Three");
Console.WriteLine("Four");
}
} 출력
OneTwoThree Four