5 Features in C# 10 Every Developer Should Know
Tags: csharp, dotnet
Published: 2022-01-17 12:50:07

---
title: 5 Features in C# 10 Every Developer Should Know
published: true
date: 2022-01-17 12:00:45 UTC
tags: csharp, dotnet
canonical_url: https://www.syncfusion.com/blogs/post/5-features-in-c-sharp-10-every-developer-should-know.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/phdtiaw7qx77bfzkp43e.png
---

C# is one of the oldest and fast-growing programming languages in the world. This blog lists the top five features in C# 10 that help developers write code faster and prettier:

1. [Constant interpolated strings](#constant-interpolated-strings).
2. [Extended property patterns](#extended-property-patterns).
3. [Global using](#global-using).
4. [File-scoped namespace](#file-scoped-namespace).
5. [Assignment and declaration in the same deconstruction](#assignment-and-declaration-in-the-same-deconstruction).

Let’s look at each of these features.

**Note:** With the details provided in the [C# language versioning](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version "Documentation link to C# language versioning"), C# 10 is supported only on .NET 6 and newer versions.

## 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 an expression. 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, and 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.

Look at the following code example for more clarity.

```csharp
const string Name = "Alan";
const string Designation = $"{Name} - Employee";
```

![Constant Interpolated String in C# 10](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/Constant_Interpolated_String.png)

## Extended property patterns

Extended property patterns help us to improve the readability of code in accessing a child property from a parent property. In C# versions prior to 10, the child properties were inaccessible at the same level.

### C# 8

```csharp
{ ParentProperty: { ChildProperty: Value } }
```

### C# 10

```csharp
{ ParentProperty.ChildProperty: Value }
```

![Extended Prpoperty Patterns in C# 10](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/Extended-Prpoperty-Patterns-in-C-10.png)

## Global using

Use the new global using feature in the C# 10, to avoid referring to the same directive in each class and page. Adding the **global** modifier as a prefix to the **using** namespace or directive will apply the reference to all files in the project.

```csharp
global using System;
```

![Global Using in C# 10](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/Global-Using-in-C-10.png)

## File-scoped namespace

With the new file-scoped namespace declaration in C# 10, you can declare a single namespace for the entire file. After declaring the file-scoped namespace, we can’t declare any other namespace. You can only declare and define the following types:

- Class
- Struct
- Delegate
- Enum
- Interface

### Old format

```csharp
namespace ConsoleAppcore
{
    internal class User
    {
    }
}
```

![File_Scoped_Old](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/File_Scoped_Old.png)

### New format for C# 10

```csharp
namespace ConsoleAppcore;
internal class User
{
}
```

![File Scope namespace in C# 10](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/File-Scope-namespace-in-C-10.png)  
To use this feature in all the new classes to be created, follow these steps in Visual Studio 2022:

1. First, right-click the project. Then, choose **Add** > **New EditorConfig**.
2. Now, open the Editor configuration file.
3. Move to the **Code Style** tab.
4. Finally, change **Namespace declarations** to **File Scoped** from **Block Spaced** and save the file.
5. Hereafter, creating a new CS file will use the file-scoped format. ![File Scoped Configuration in Visual Studio](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/File-Scoped-Configuration-in-Visual-Studio.png)

## Assignment and declaration in the same deconstruction

In the previous versions of C#, developers can either assign values to existing variables or declare new variables in deconstruction. The combination of assigning a value to an existing variable and declaring a new variable was restricted. This restriction is now removed, and you can assign a value and declare a new variable in a single deconstruction.

### Before C# 10

```csharp
(string name, string email) = var employee;

Or
string name;
string email;
(name, email) = employee;
```

### In C# 10

```csharp
string name;
(name, string email) = employee;
```

![Assignment And Declaration in C# 10](https://www.syncfusion.com/blogs/wp-content/uploads/2022/01/Assignment-And-Declaration-in-C-10.png)

## Conclusion

Thank you for reading this blog post. I hope you now have a good idea about the top five features in C# 10. Use these features when coding with C# 10 to make your code more readable and productive.

Syncfusion provides more than 1,700 components and frameworks to ease app development on various platforms. We encourage you to evaluate the components and use them as needed for application development:

<table>
<tbody>
<tr style="background: none;">
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Blazor UI controls" href="https://www.syncfusion.com/blazor-components">Blazor</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Flutter UI controls" href="https://www.syncfusion.com/flutter-widgets">Flutter</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to ASP.NET Core UI controls" href="https://www.syncfusion.com/aspnet-core-ui-controls">ASP.NET Core</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to ASP.NET MVC UI controls" href="https://www.syncfusion.com/aspnet-mvc-ui-controls">ASP.NET MVC</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to ASP.NTE Web Forms UI controls" href="https://www.syncfusion.com/jquery/aspnet-web-forms-ui-controls">ASP.NTE Web Forms</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to JavaScript UI controls" href="https://www.syncfusion.com/javascript-ui-controls">JavaScript</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Angular UI controls" href="https://www.syncfusion.com/angular-ui-components">Angular</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to React UI controls" href="https://www.syncfusion.com/react-ui-components">React</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Vue UI controls" href="https://www.syncfusion.com/vue-ui-components">Vue</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to jQuery UI controls" href="https://www.syncfusion.com/jquery-ui-widgets">jQuery</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to .NET MAUI controls" href="https://www.syncfusion.com/maui-controls">.NET MAUI (Preview)</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Xamarin UI controls" href="https://www.syncfusion.com/xamarin-ui-controls">Xamarin</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to UWP UI controls" href="https://www.syncfusion.com/uwp-ui-controls">UWP</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to WinForms UI controls" href="https://www.syncfusion.com/winforms-ui-controls">WinForms</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to WPF UI controls" href="https://www.syncfusion.com/wpf-controls">WPF</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to WinUI controls" href="https://www.syncfusion.com/winui-controls">WinUI</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Excel Library" href="https://www.syncfusion.com/excel-framework/net">Excel Library</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to PDF Library" href="https://www.syncfusion.com/pdf-framework/net">PDF Library</a></td>
</tr>
<tr>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to Word Library" href="https://www.syncfusion.com/word-framework/net">Word Library</a></td>
<td style="text-align: center; border: none !important;" width="312"><a title="Link to PowerPoint Library" href="https://www.syncfusion.com/powerpoint-framework/net">PowerPoint Library</a></td>
</tr>
</tbody>
</table>

If you have any questions or comments, you can contact us through our [support forums](https://www.syncfusion.com/forums "Link to the Syncfusion support forum"), [support tickets](https://support.syncfusion.com/ "Link to the Syncfusion support portal"), or [feedback portal](https://www.syncfusion.com/feedback/winui "Link to Syncfusion Feedback Portal"). As always, we are happy to assist you!

## Related blogs

- [10 Best C# NuGet Packages to Improve Your Productivity in 2022](https://www.syncfusion.com/blogs/post/10-best-c-nuget-packages-to-improve-your-productivity-in-2022.aspx "Link to 10 Best C# NuGet Packages to Improve Your Productivity in 2022 blog")
- [5 Easy Ways to Protect Excel Data in C#](https://www.syncfusion.com/blogs/post/5-easy-ways-to-protect-excel-data-in-c.aspx "Link to 5 Easy Ways to Protect Excel Data in C# blog")
- [Pattern Matching in C# for Beginners](https://www.syncfusion.com/blogs/post/pattern-matching-in-c-for-beginners.aspx "Link to Pattern Matching in C# for Beginners blog")
- [Understanding C# Anonymous Types](https://www.syncfusion.com/blogs/post/understanding-csharp-anonymous-types.aspx "Link to Understanding C# Anonymous Types blog")