dotnet-csharp-modern-patterns

Guide adoption of modern C# features across .NET Target Frameworks.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-csharp-modern-patterns-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-csharp-modern-patterns
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/dotnet-csharp-modern-patterns
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-csharp-modern-patterns-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guidance on leveraging modern C# language features to write more concise, expressive, and maintainable code, adapting to different .NET Target Frameworks (TFMs).

Core Features & Use Cases

  • Modern Syntax: Learn to use records, primary constructors, collection expressions, and pattern matching effectively.
  • Language Versioning: Understand which features are available for specific .NET TFMs (e.g., C# 12 for .NET 8.0, C# 14 for .NET 10.0).
  • Use Case: Refactor existing C# code to use record types for DTOs, implement primary constructors for cleaner service initialization, and utilize collection expressions for simplified list creation.

Quick Start

Use the dotnet-csharp-modern-patterns skill to understand how to use records for immutable data transfer objects.

Frequently Asked Questions about dotnet-csharp-modern-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use C# records for immutable data transfer objects?

C# records provide built-in value-based equality and immutability, making them ideal for data transfer objects. You can refactor existing classes to record types to achieve concise, expressive syntax for immutable data structures across .NET Target Frameworks.

What's the best way to implement primary constructors in modern C#?

Primary constructors in modern C# allow you to declare constructor parameters directly on the type declaration, providing cleaner service initialization. This feature is available in C# 12 and later, targeting .NET 8.0 and above.

Does pattern matching work with older .NET Target Frameworks?

Advanced pattern matching features depend on your specific .NET Target Framework Moniker (TFM). The skill provides polyfill strategies and multi-targeting guidance to help you adopt modern C# pattern matching even when targeting older framework versions.

Can I use collection expressions to simplify list creation in C#?

Collection expressions in modern C# simplify list creation by providing a unified syntax for initializing collections. You can use them across various .NET TFMs, with feature availability detailed by language version from C# 12 through C# 15.

When should I use polyfill strategies for modern C# language features?

Use polyfill strategies for modern C# language features when you need to multi-target older .NET frameworks that lack native support. This approach allows you to leverage newer syntax like the `field` keyword while maintaining compatibility with earlier TFM versions.

What C# language features are available for .NET 10.0?

C# 14 features, including extension blocks and the `params` collections modifier, are available for .NET 10.0. The skill details feature availability by TFM, mapping language versions from C# 12 through C# 15 to their corresponding .NET runtimes.