TL;DR: Discover the top five powerful features of C# 10 that simplify coding and improve clarity. These powerful enhancements are available on .NET 6 and newer versions, making your development process more efficient.
C# has been a developer favorite for years, and with C# 10, it just got even better! This version introduces features that make your code cleaner, faster, and easier to maintain.
In this blog, we’ll highlight five essential C# 10 features and how each can help you write cleaner, more efficient code:
- File-scoped namespace
- Global using directives
- Record structs
- Improved lambda expressions
- Constant interpolated strings
Now that we’ve outlined these powerful features, let’s explore each one in detail to understand how they can enhance your C# development process.
Note: According to the details provided in the C# language versioning, C# 10 is supported only on .NET 6 and later versions.
File-scoped namespace
With the file-scoped namespace declaration in C# 10, you can declare a single namespace for the entire file. After declaring a file-scoped namespace, no other namespace can be declared. You can only declare and define the following types:
- Class
- Struct
- Delegate
- Enum
- Interface
Old format
namespace ConsoleAppcore
{
internal class User
{
}
}

New format for C# 10
namespace ConsoleAppcore;
internal class User
{
}

To use this feature in all the new classes to be created, follow these steps in Visual Studio 2026:
- First, right-click the project. Then, choose “Add” -> “New EditorConfig”.
- Now, open the Editor configuration file.
- Move to the Code Style tab.
- Finally, change Namespace declarations to File Scoped from Block Scoped and save the file. Hereafter, creating a new CS file will use the file-scoped format.

Global using
In C# 10, global using feature prevent repetition of using directives in every class or file. By adding the global modifier before a using statement, it applies across all project files, helping to keep code concise and consistent.
global using System:

Record Structs
Record Structs, introduced in C# 10, are value-type records. They offer value-based equality, with-expressions, and primary constructor syntax, along with a synthesized ToString() method. As value types, they can help reduce heap allocations, although the actual allocation depends on how they are used.
Record Structs are particularly well-suited for small, often immutable data, such as coordinates, configuration values, and domain value objects. When you need immutability, use the read only record struct.
Refer to the following code example.
// Positional record struct
public readonly record struct Point(double X, double Y);
// Record struct with methods
public readonly record struct Temperature(double Celsius)
{
public double Fahrenheit => (Celsius * 9 / 5) + 32;
public Temperature AddDegrees(double degrees) => this with { Celsius = Celsius + degrees };
}
// Mutable record struct (use with caution)
public record struct MutablePoint(double X, double Y);

Improved lambda expressions
C# 10 adds natural type inference to lambda expressions. It allows the compiler to automatically deduce delegate types, introduces support for attributes on lambda parameters and return values. These enhancements enable more type-safe and expressive functional programming. This will particularly benefit minimal APIs, LINQ queries, and metadata-driven lambda configuration.
Natural type inference
It eliminates the need for explicit Func<> or Action<> declarations when assigning to var and supports explicit return type syntax like int (string s) => … for type clarity.
// C# 10 can infer the delegate type
var parse = (string s) => int.Parse(s);
var choose = (bool condition) => condition ? 1 : "two"; // Compiler error: ambiguous type
// Explicit return types
var parseWithDefault = int (string s) => int.TryParse(s, out var result) ? result : 0;

Attributes on lambda expressions
Lambda parameters and expressions can now use attributes like [Authorize], [FromBody], and [NotNull], providing declarative metadata for validation, authorization, and dependency injection. This improves code readability and maintainability, especially in ASP.NET Core Minimal APIs where lambdas act as endpoint handlers.
// Apply attributes to lambda parameters and return values
var validate = ([NotNull] string? input) =>
{
if (string.IsNullOrEmpty(input))
throw new ArgumentException("Input cannot be null or empty");
return input.ToUpper();
};
// Useful for minimal APIs and dependency injection
app.MapGet("/users/{id}",
[Authorize]
async (int id, IUserService service) => await service.GetUserAsync(id));
Constant interpolated strings
String interpolation, introduced in C# 6, provides an easy and convenient way to apply syntax to a string. An interpolated string is usually a combination of strings and expressions. On resolving an interpolated string to a string, the expression is executed, and the resultant string value is added in its place.
Back then, string interpolation was restricted only to strings. A string declared as a constant cannot be interpolated. But now in C# 10, this string interpolation feature is extended to strings declared as constants as well, with the condition that only constant strings can be used in the expression.
Refer to the following code example for further clarity.
const string Name = "Alan";
const string Designation = $"{Name} - Employee";

Conclusion
Thanks for reading! C# 10 isn’t just an update; it’s a productivity boost! These five features will help you write cleaner, smarter, and more maintainable code. Start using them today and see the difference. Got questions or tips? Share them in the comments, we’d love to hear from you!
You can also contact us through our support forums, support portal, or feedback portal. As always, we are happy to assist you!