IT

Visual Studio 2015에서 C # 7을 사용하는 방법은 무엇입니까?

lottoking 2020. 6. 21. 19:10
반응형

Visual Studio 2015에서 C # 7을 사용하는 방법은 무엇입니까?


Visual Studio 2017 (15.x)은 C # 7을 지원하지만 Visual Studio 2015 (14.x)는 어떻습니까?

C # 7을 어떻게 사용합니까?


Nuget 패키지 Microsoft.Net.Compilers를 설치하여 C # 7 지원 버전의 Visual Studio와 함께 제공된 컴파일러를 교체 할 수 있습니다 .

이 패키지를 참조하면 시스템에 설치된 버전과 달리 패키지에 포함 된 특정 버전의 C # 및 Visual Basic 컴파일러를 사용하여 프로젝트가 빌드됩니다.

패키지 페이지에서 이것이 Visual Studio 2015에서 공식적으로 지원되는지 여부를 알 수있는 징후는 없습니다. 지금까지 철저한 테스트를 거치지 않았지만 아무런 문제없이 C # 7 코드가 컴파일되지만 빨간색으로 밑줄이 그어져 있습니다. 구문 오류를 나타내는 구불 구불 한 줄 : 새로운 C # 7 값 튜플 기능을 사용하려면 스크린 샷Nuget 패키지 System.ValueTuple도 설치해야 합니다.


필자의 경우 Microsoft.Net.Compilers 만 설치하면 작동하지 않습니다. 대신 다음을 수행해야했습니다.

  1. Install Microsoft.CodeDom.Providers.DotNetCompilerPlatform for the project (Tools => NuGet Package Manager => Manage Nuget Packages for Solution...) and install Microsoft.CodeDom.Providers.DotNetCompilerPlatform.
  2. Install the latest Microsoft.Net.Compilers for the project
  3. Install any other NuGet package for the latest C# feature you want to use. In my case, my goal was to use Tuples, so I installed System.ValueTuple and worked fine.

But still note that C# codes which are not known by Visual Studio 2015 default compiler will still have red squiggles underneath.

참고 URL : https://stackoverflow.com/questions/39461407/how-to-use-c-sharp-7-with-visual-studio-2015

반응형