New in .NET 9.0 (3): Features in the C# 13.0 programming language

0
14
New in .NET 9.0 (3): Features in the C# 13.0 programming language


Microsoft officially only supports C# 13.0 newer than .NET 9.0 (“C# 13.0 is only supported on .NET 9 and newer versions.”).

Advertisement




Open Source in the Global South – More than just a technical toolOpen Source in the Global South – More than just a technical tool


Dr. Holger Schweitenberg is the technical director of the expert network www.IT-Visions.de, which supports many medium-sized and large companies through consulting and training as well as software development with 53 renowned experts. Through his attendance at numerous national and international conferences as well as more than 90 expert books and more than 1,500 expert articles, Holger Schwittenberg is one of the best-known experts for .NET and web technologies in Germany.

However, most of the language features of C# can also be used in older .NET versions, including .NET Framework, .NET Core, and Xamarin. To do this you need to check the compiler version used per tag Until “13.0” in the project file (.csproj).

13.0

For language features to work in versions prior to .NET 9.0, they must not have dependencies on base library classes introduced in .NET 9.0. unless you latest In the project file, the following new language features of C# 13.0 are possible in earlier versions:

  • Partial properties and partial indices
  • Common set associated with params keyword
  • innovation for ref structExcept for use as a type argument
  • escape character \e

However, it should be noted that there is no technical support from Microsoft for the use of new language features in .NET versions prior to 9.0, so you cannot use the support agreement to ask Microsoft for help if you have problems. Can do. Nevertheless, using higher C# versions in older .NET projects is a common and problem-free practice in some companies.

The following new language features have appeared in C# 13.0, which I will discuss in this blog series in the coming weeks:

  • partial attributes and partial indexes,
  • new escape character \e For ANSI/VT100 terminal control escape sequences,
  • Preferences for method overloading,
  • common set type params,
  • Object initialization with index operator from end,
  • new class Threading.Lock For lock-instructions and
  • extension for ref structs (on the stack).

Another language feature has been included in C# 13.0 in experimental form: semi-automatic properties with new keywords. fieldThis keyword is only available in the project file True Or preview set.

The following language features were planned for C# 13.0 and some were already available as prototypes, but were then released C# 14.0 postponedWhich is scheduled to release in November 2025:

  • tuple deconstruction(int x, string y) = default instead of (default, default)
  • automatic conversion between Array, Span And ReadOnlySpan
  • Extensions: A more developed, generalized form of extension methods in which you can add not only instance methods, but methods and properties at both the instance and class level (“static”). Microsoft wants new keyword for this extensionintroduce.

there are some some breaking changes Compiler behavior in C# 13.0 compared to C# 12.0. However, these are special cases of less importance, such as restrictions on annotations. (InlineArray) But record struct,


(rme)

iX Workshop: Programming More Productively with Github Copilot and ChatGPTiX Workshop: Programming More Productively with Github Copilot and ChatGPT

LEAVE A REPLY

Please enter your comment!
Please enter your name here