Web appOpen in Telegram

PostC# 14 - Extension Members 🚀

29 April 2025
M
Link
click to show
C# 14 - Extension Members 🚀 C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods. ✔️ You can also declare extension members that extend the type, rather than an instance of the type. In other words, these new extension members can appear as static members of the type you extend. The following code example shows an example of the different kinds of extension members you can declare: public static class Enumerable { // Extension block extension<TSource>(IEnumerable<TSource> source) // extension members for IEnumerable<TSource> { // Extension property: public bool IsEmpty => !source.Any(); // Extension indexer: public TSource this[int index] => source.Skip(index).First(); // Extension method: public IEnumerable<TSource> Where(Func<TSource, bool> predicate) { ... } } // extension block, with a receiver type only extension<TSource>(IEnumerable<TSource>) // static extension members for IEnumerable<Source> { // static extension method: public static IEnumerable<TSource> Combine(IEnumerable<TSource> first, IEnumerable<TSource> second) { ... } // static extension property: public static IEnumerable<TSource> Identity => yield return default; } } The members in the first extension block are called as though they're instance members of IEnumerable<TSource>, for example sequence.IsEmpty. The members in the second extension block are called as though they're static members of IEnumerable<TSource>, for example IEnumerable<int>.Identity. [ Blog ] : https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods 〰️〰️〰️〰️〰️〰️ #csharp #dotnet @ProgrammingTip
16 · 17.1K ·

Nearby in the feed

MMoien TajikA Structured Roadmap to Master Software Testing for Developers 🚀 Struggling to navigate the world of testing? 💭 I’ve compiled a comprehensive roadmap to help deMMoien TajikBuild a Model Context Protocol (MCP) Server in C# 🧠 Learn how to create an MCP server using .NET 8 and ASP.NET Core! ⚡️ This guide walks you through building a
this message
MMoien TajikHow to use MCP in n8n to scale AI automation? 🤔 We break down exactly what n8n and MCP are and demonstrate why using them together is a game-changer for automatMMoien TajikCursor can now make to-do lists, search PRs, and queue messages 👾 [ Blog ] : https://cursor.com/changelog/1-2 〰️〰️〰️〰️〰️〰️ #AI #Agents #Cursor @ProgrammingTip
PProgramming & AI Tips 💡Programming & AI Tips 💡@ProgrammingTip · channel · Tech
46 321subscribers2 321average post reach
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · What we do not do · Remove a page · Catalog · Search · How we count