Skip to content

1kevgriff/Griffin.CSharp14Demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C# 14 Feature Demonstrations

A collection of hands-on demonstrations showcasing the latest features in C# 14, with side-by-side comparisons to traditional approaches.

Overview

C# 14 introduces powerful new language features that improve code expressiveness, reduce boilerplate, and better align syntax with semantic intent. This repository provides practical, real-world examples of these features to help developers understand not just what changed, but why it matters.

Each demo includes:

  • Problem Statement - What limitation existed in previous C# versions
  • Solution - How C# 14 addresses it
  • Side-by-Side Comparison - Traditional vs. modern approach
  • Real-World Examples - Practical usage scenarios
  • Detailed Explanations - Why the new way is better

Requirements

  • .NET 10 SDK (or later)
  • C# 14 language support
  • Any IDE with C# support (Visual Studio 2025+, JetBrains Rider, VS Code)

Verify Your Setup

dotnet --version  # Should show 10.x or higher

Getting Started

Clone the Repository

git clone <repository-url>
cd Griffin.CSharp14Demos

Build All Demos

dotnet build Griffin.CSharp14Demos.sln

Run a Specific Demo

cd Demo_ExtensionMethods
dotnet run

Demos

1. Extension Members

Location: Demo_ExtensionMethods/

What it demonstrates: The evolution from extension methods to extension members, allowing property-like syntax for characteristics instead of forcing method call syntax.

Key Concept:

// Old Way: Extension Method (requires parentheses)
var monday = date.MondayOfCurrentWeek();

// New Way: Extension Member (property syntax)
var monday = date.MondayOfCurrentWeek;

Run it:

cd Demo_ExtensionMethods
dotnet run

📖 Read the full demo documentation


More Demos Coming Soon!

This repository will be expanded with additional C# 14 feature demonstrations including:

  • Params collections
  • Field keyword in properties
  • Lock object improvements
  • And more...

Repository Structure

Griffin.CSharp14Demos/
├── Griffin.CSharp14Demos.sln          # Solution file
├── README.md                          # This file
├── CLAUDE.md                          # AI assistant guidance
│
├── Demo_ExtensionMethods/             # Extension Members demo
│   ├── Demo_ExtensionMethods.csproj
│   ├── Program.cs
│   ├── DateTimeExtensions.cs         # Traditional approach
│   ├── DateTimeExtensionMembers.cs   # C# 14 approach
│   └── README.md
│
└── [Future Demos]/

Contributing New Demos

Want to add a new C# 14 feature demonstration? Follow this pattern:

  1. Create a new project folder: Demo_{FeatureName}/
  2. Configure for C# 14:
    <TargetFramework>net10.0</TargetFramework>
    <LangVersion>14.0</LangVersion>
  3. Include both approaches: Show the old way vs. the new C# 14 way
  4. Add comprehensive README: Explain the problem, solution, and real-world usage
  5. Create runnable demo: Program.cs with clear console output
  6. Update this README: Add your demo to the demos list

Why This Repository?

C# 14 isn't just about new syntax - it's about writing code that says what it means. These demos focus on:

  • Semantic Clarity - Code that reads like natural language
  • Practical Application - Real-world scenarios, not just toy examples
  • Comparative Learning - Understanding why the new way is better
  • Educational Value - Teaching through clear, documented examples

Learn More

License

This repository is for educational purposes.


Each feature demonstration is designed to be self-contained and runnable. Explore each demo's README for detailed explanations and sample output.

About

C# 14 Demos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages