Knowledge from
experts for free

18 April 2023
  • 3 min read
  • What’s new in C# 12:

    • Basic constructors

    Version 12 of the C# language added basic constructors for classes and structures. Initially, they were available only for the records. Parameters specified in such a constructor are available in the scope of the entire class. Adding this kind of constructor will prevent the compiler from creating a parameterless constructor. However, it is possible to add other constructors. You only need to remember to call the base constructor using this(). This solution will make the code more readable and reduce unnecessary constructor declarations.

    •  Any type aliasing

    Another of the new features is aliasing of any type. The creation of an alias can be done via the using directive. The newly created type is available within a given file unless it is declared as global. This will help increase the clarity and readability of the created solutions.

    • Default lambda expression parameters

    Default expression parameters can now be declared in the same way as default function parameters. As a result, developers will not have to use the DefaultParameterValue attribute. Moreover, these values are available in the metadata, making them accessible via reflection.

    What’s new in C# 12:

    18 April 2023
  • 3 min read
  • This site is registered on wpml.org as a development site.