Modern C# Language Features

Intermediate Updated March 21, 2025

🔍 Modern C# Language Features

| Feature                    | Example / Explanation                                      |
|----------------------------|------------------------------------------------------------|
| Expression-bodied members  | `public int Square(int x) => x * x;`                       |
| Pattern matching           | `if (x is int number && number > 0)`                       |
| Null-coalescing operator   | `string name = input ?? "Unknown";`                        |
| `switch` expressions       | `var result = x switch { 1 => "One", _ => "Other" };`      |
| Records (C# 9+)            | `record Person(string Name, int Age);`                     |
| Nullable reference types   | `string? email = null;`                                    |