
1. Params Span<T>: Better Performance, No Allocations
C# 13 introduces the ability to use params Span<T>
or ReadOnlySpan<T>
in method parameters. This means you can now write high-performance APIs that use params
—without the hidden allocations that typically come with arrays.
Why it matters:
- Great for performance-critical code (e.g. parsing, math, game logic).
- Works seamlessly with stack-allocated memory.
void Log(params ReadOnlySpan<char>[] lines) { foreach (var line in lines) Console.WriteLine(line); }
2. Field keyword (Proposed / Experimental)
The new field
keyword allows referencing the current field in attributes. For example, you can specify metadata for serialization or mapping libraries without hardcoding the field name.
[JsonPropertyName(field)] private string userName;
Why it matters:
- Helps eliminate magic strings.
- Improves maintainability in meta-programming and source generators.
3. Collection Expressions (Preview)
Although introduced in C# 12, collection expressions continue to improve in C# 13 with better compiler support and type inference. You can now declare arrays, lists, spans, and more using a unified syntax:
var nums = [1, 2, 3, 4]; // Can be an array, List<int>, or Span<int>
Why it matters:
- Cleaner, more expressive collection initialization.
- Makes code feel more modern and aligned with languages like Python or JavaScript.
4. Better Interpolated Strings
C# 13 enhances interpolated string handlers, giving library authors more control over formatting, performance, and compile-time optimizations.
This means interpolated strings can be parsed more efficiently, especially in logging frameworks and performance-sensitive contexts.
logger.LogInfo($"User {userId} performed action {action}");
Under the hood, this may now use custom handlers that avoid unnecessary allocations or string building unless the log level is enabled.
5. Alias any type with using
This one might be small but useful: you can now alias almost any type, including tuples, pointer types, and function pointers.
using UserData = (string Name, int Age, bool IsActive);
Why it matters:
- Improves readability for complex return types.
- Reduces duplication in APIs and internal logic.
6. Preview Features from C# 12 Stabilized
C# 13 also stabilizes several features introduced in C# 12, such as:
- Primary constructors for classes
required
members- Default lambda parameters
- Inline arrays
These features are now production-ready and usable in stable .NET 9 builds.
7. Quality-of-Life Improvements
C# 13 isn’t about massive changes—it’s about smoothing rough edges:
- Better compiler diagnostics.
- Improved type inference in generic scenarios.
- Fewer surprises when using pattern matching with
is
andswitch
.
These changes make the language more predictable and reduce friction when building large systems or refactoring code.
Final Thoughts
C# 13 continues the trend we’ve seen in recent years: smaller, more focused updates that improve ergonomics, performance, and developer experience without radically changing the language.
If you’re already using C# 10–12, the upgrade will feel natural—and you’ll appreciate the added expressiveness. If you’re maintaining older codebases, it might be the right time to modernize and take advantage of what C# has become: a clean, powerful, and battle-tested language ready for everything from APIs to games to cloud services.
Become a member
Get the latest news right in your inbox. It's free and you can unsubscribe at any time. We hate spam as much as we do, so we never spam!