Microsoft MVP성태의 닷넷 이야기
글쓴 사람
혜성
홈페이지
첨부 파일
 

Visual Studio 2022 이전에는 C# 콘솔 프로젝트를 만들면 Program.cs 에 아래 형태로 기본코드가 생성되었는데

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}



Visual Studio 2022 부터는 Progrma.cs 에 아래처럼 Main 함수가 없는 형태로 생성이됩니다

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");






이렇게 바뀐 이유가 무엇이고 어떤 장점이 있는건가요?








[최초 등록일: ]
[최종 수정일: 10/26/2022]


비밀번호

댓글 작성자
 



2022-10-26 06시21분
C# 9부터 추가된,

C# 9.0 - (15) 최상위 문(Top-level statements)
; https://www.sysnet.pe.kr/2/0/12406

최상위 문이 .NET 6.0 이상의 프로젝트부터 적용되면서 Main 함수가 없는 유형으로 바뀐 것입니다. 이에 대한 선택을 프로젝트 생성 단계에서 "Do not use top-level statements" 체크박스를 통해 선택할 수도 있으니 딱히 불편한 사항은 아닙니다.

VS now includes a "Do not use top-level statements" option when scaffolding projects for users who do not want to use the new minimal API features
; https://www.reddit.com/r/dotnet/comments/unajcd/vs_now_includes_a_do_not_use_toplevel_statements/
정성태
2022-10-26 07시53분
[혜성] 최상위 프로그램 이라는 이름을 몰라서 검색하기도 어려웠는데
답변 감사합니다!!
[guest]

NoWriterDateCnt.TitleFile(s)