Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

499
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda