C# 14 Lambda type inference with out parameter
| | |

C# 14: Simplified parameters with modifiers in lambdas

Lambda expressions have been a core feature of C# for many years, allowing developers to write inline functions or callbacks in a concise way. In C#, a lambda can have explicitly typed parameters (where you specify each parameter’s type) or implicitly typed parameters (where the types are inferred from context). Prior to C# 14, if…

| | |

Partial constructors and events in C# 14

C# 14 introduces a new capability to declare instance constructors and events as partial members. This means you can split a constructor or event definition across two parts of a partial class, similar to how C# has long allowed partial methods and partial properties. This means that, one part of a partial class can declare…

| | |

C# 14: nameof support for unbound generic types

C# 14 introduces several small but helpful improvements to the language. One of these new features is an enhancement to the nameof expression – it now supports unbound generic types. In simple terms, you no longer need to plug in a placeholder type argument just to get the name of a generic type. This update…

| | |

Implicit Span conversions in C# 14 – First-class support for Span and ReadOnlySpan

C# 14 introduces a significant enhancement for high-performance code: first-class language support for spans. In particular, it adds new implicit conversions between Span<T>, ReadOnlySpan<T>, and arrays (T[]). This change makes it much easier to work with these types that represent safe, contiguous memory slices without extra allocations. In this article, we’ll explore what span conversions…

| | |

C# 14 – The field keyword and field-backed properties

C# 14 introduces a new contextual keyword, field, that can be used inside a property’s accessors (the get, set, or init blocks) to refer to the property’s backing storage​. In simpler terms, field is a placeholder representing the hidden variable where a property’s value is stored. This keyword lets you add custom logic to automatically…

| | |

.NET Performance: ToList vs ToArray

.NET 9 brings significant improvements to LINQ’s ToArray method, both in terms of speed, as well as memory allocation. To achieve this, the new implementation makes use of new runtime features such as InlineArray to significantly reduce memory allocations and improve speed, especially when dealing with an IEnumerable<T> of unknown length. If you’re curious about the implementation,…

| | |

C# 13: Use params collections with any recognized collection type

The params modifier in C# has traditionally been associated with array types, allowing methods to accept a variable number of arguments. However, starting with C# 13, you can now use params collections with a variety of collection types, broadening its applicability and making your code even more versatile. Supported collection types The params modifier now…

| | |

How to switch to C# 13

While trying out C# 13 features, it’s possible you might come across errors similar to these: Feature is not available in C# 12.0. Please use language version 13.0 or later. or Error CS8652: The feature ‘<feature name>’ is currently in Preview and unsupported. To use Preview features, use the ‘preview’ language version. There are two…

|

C# language version history

C# 1.0 Introduced with .NET Framework 1.0 in January 2022, C# 1.0 established the foundation of the language with basic object-oriented programming features, including classes, structs, interfaces, events, properties, and delegates. The language had the following goals: C# 2.0 Introcudec in 2005, this version brought significant enhancements such as generics for type-safe data structures, anonymous…

| |

MAUI: How to register handlers in a library

Whether you are developing a custom controls library or simply organizing your solution into multiple project, you will most likely end up in the situation where you want to register some view handlers and services from within a MAUI library. To start off, there’s no such thing as zero-configuration registration. MAUI uses a builder pattern…