using static 구문
C# 6.0 이후부터는 using static System.Console; 구문으로 System.Console을 생략한 WriteLine() 메서드만 사용할 수 있습니다. Console 클래스의 WriteLine() 메서드는 C#을 학습할 때 워낙 많이 사용하는 구문이기에 using static 구문으로 위쪽에 System.Console을 정의해 두면 WriteLine() 메서드만 호출해도 됩니다.
//WriteLineDemo.cs
using static System.Console;
class WriteLineDemo
{
static void Main()
{
WriteLine("명령 프롬프트에 출력할 내용");
}
}
명령 프롬프트에 출력할 내용
다음 샘플 코드처럼 구문 2개를 동시에 위쪽에 둘 수도 있습니다. 형태만 참고하세요.