Categories
.NET .NET 10 .NET MAUI Android Blazor C# Code Deep Dive Desktop Developer Getting Started Hybrid iOS Learn Mobile Preview Visual Studio VS Code Web What's New Windows Xamarin Xamarin.Forms

What’s New in C# 14 – Extension Members – A Comprehensive Guide

Introduced in C# 3.0, extension methods are a valuable feature for external types, especially when those types are sealed, such as string.

Roughly two decades later, C# has now finally unveiled support for extending everything.

With the release of .NET 10 Preview 3 (C# 14), it is now possible to define static methods, instance properties, and static properties too. Support for other members will be incorporated in future releases.

Syntactically, an extension method should be defined within a top-level static class. The type of its first mandatory parameter, the one qualified with the this keyword, determines the type being extended. Henceforth, this will be referred to as the receiver type.

All standard query operators of LINQ are defined as extension methods. They are defined in the Enumerable static class within the BCL (in the System.Linq namespace).

For example, the Where extension method applies to all types that implement IEnumerable<T>. Validations and optimizations aside, the typical implementation is as outlined below.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer General Hybrid iOS macOS Mobile Toolkit Web What's New Windows Xamarin Xamarin.Forms

Enhance Gesture Binding with the Shared Toolkit

The year 2024 began with an article outlining the improvements in the Shared Toolkit through the optimization of specifying the Binding as a LINQ expression, without requiring an additional getter or setter.

Mainly, the Binding expression is statically typed, providing better control by aiding in identifying errors during compilation. Furthermore, it preserves the default binding behavior of the View, such as the two-way binding in the case of Entry, enabling editing. This behavior can be modified using the BindingMode parameter.

Categories
.NET .NET 8 .NET MAUI Android Code Desktop Developer iOS Mobile MVVM NuGet Toolkit What's New Windows WinUI 3 Xamarin

Data and Command Bindings – Made Easy with Shared Toolkit

First things first, wishing you all a very happy, healthy, and prosperous new year 2024.

2023 wrapped with the release of a newer version of VijayAnand.Toolkit.Markup (aka SharedToolkit), which comes with the wrapper method that allows specifying the Binding as a LINQ expression without the need to specify an additional getter or setter.