Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

500
Visualizações
How could a project use target type object creation if it is a .NET 4.8 project?

I am looking at and following example code that has the following lines:

public static DispenseOptionSketchVolume DoSketchVolume = new();
public static SketchSettingsPageData SketchSettingsPageData = new();
public static BlockVolumeData BlockVolumeData = new();
public static SketchEntityVolumePage SketchEntityVolume = new();

In my own project I created a framework 4.8 class library but get the error:

Feature 'target typed object creation' is not available. Please use language version 9.0 or greater. new(); is the error.

If I add this to my own csproj:

<PropertyGroup>
    <LangVersion>9.0</LangVersion>
</PropertyGroup>

Visual Studio asks me to attach to a process: enter image description here

In the example project the framework is set to 4.8, the type is a class Library, there is a framework that automatically registers the dll and it runs. There is no <LangVersion> directive in any file csproj or otherwise.

How could the example project compile the = new(); statements?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I just set <LangVersion>9.0</LangVersion> on a large .NET Framework 4.8 solution and it works as expected. The target-typed new is available and no error messages are shown. I successfully tried both VS2019 and VS2022. So it seems this does work. Maybe you need to make sure you're building with at least the .NET 5.0 compiler. Make sure your global.json is requiring at least a 5.0 SDK.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda