기존에는 '타입명.static메소드명' 으로 호출하지만,
이제는 'using static 타입의전체이름'을 선언하면
타입명 없이 바로 메소드를 호출할 수 있다.
✍ 기존의 static 메서드 호출
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello");
}
}
✍ using static
using static System.Console;
class Program
{
static void Main(string[] args)
{
WriteLine("Hello");
}
}
enum 타입의 멤버와 const 상수 멤버도 컴파일하면 내부적으로 모두 static 유형으로 다뤄지기 때문에, 이들도 동일하게 타입명을 생략하여 호출할 수 있다.