
1️⃣ extension
New keyword in C# 14 😍
Allows adding methods to existing classes without modifying their source code. Perfect for adding new behavior cleanly with new enhanced capabilities.
2️⃣ await using
Calls IAsyncDisposable to clean resources asynchronously.
3️⃣ when (catch)
Filters exceptions in catch blocks based on conditions.
4️⃣ partial
Splits class definitions into multiple files. Ideal for source-generated code or logically organizing large classes into manageable pieces.
5️⃣ readonly struct
Defines an immutable value type, with value comparison by default.
6️⃣ in
Passes parameters by reference as read-only. Avoids unnecessary copying of large structs, boosting performance without sacrificing safety.
7️⃣ extern
Indicates that a method is implemented externally, typically using native code (DLL). Allows integration of unmanaged libraries directly into your C# app.
8️⃣ volatile
Ensures the latest value of a field is always read from memory, crucial in multithreaded contexts. Helps prevent subtle concurrency bugs.
9️⃣ unsafe
Enables pointer arithmetic and direct memory manipulation.
🔟 stackalloc
Allocates memory directly on the stack instead of the heap, ideal for short-lived, high-performance scenarios.
Did you know these secret keywords? Which one surprised you the most?