{"id":368425,"date":"2021-11-17T16:00:35","date_gmt":"2021-11-17T13:00:35","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/whats-new-in-c-10\/"},"modified":"2021-11-17T16:00:35","modified_gmt":"2021-11-17T13:00:35","slug":"whats-new-in-c-10","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/","title":{"rendered":"#What\u2019s New In C# 10?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6afbb24d46e5d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6afbb24d46e5d\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#File-Scoped_Namespaces\" >File-Scoped Namespaces<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Global_Usings\" >Global Usings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Improved_Structs\" >Improved Structs<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Lambda_Expression_Enhancements\" >Lambda Expression Enhancements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Versatile_Deconstructed_Assignments\" >Versatile Deconstructed Assignments<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Other_Changes\" >Other Changes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/whats-new-in-c-10\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What\u2019s New In C# 10?&#8221;<\/strong><\/p>\n<figure id=\"attachment_14835\" style=\"width: 1200px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage size-full wp-image-14835\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/595669bf.jpg?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Illustration of C# text overlay on a photo of a laptop\" width=\"1200\" height=\"675\" \/><figcaption class=\"wp-caption-text\"><span class=\"type:primaryImage imagecredit\"><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-photo\/c-inscription-against-laptop-code-background-1862072179\">Maria Vonotna\/Shutterstock.com<\/a><\/span><\/figcaption><\/figure>\n<p>C# 10 <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/click.linksynergy.com\/deeplink?id=2QzUaswX1as&amp;mid=24542&amp;u1=csit\/14834&amp;murl=https%3A%2F%2Fdevblogs.microsoft.com%2Fdotnet%2Fwelcome-to-csharp-10\">was released in<\/a> November 2021 alongside Visual Studio 2022 and .NET 6. It adds several new features which make it easier and more convenient to work with. Here&#8217;s a tour of some of the most useful additions and how they&#8217;ll enhance your workflow.<\/p>\n<h2 id=\"file-scoped-namespaces\"><span class=\"ez-toc-section\" id=\"File-Scoped_Namespaces\"><\/span>File-Scoped Namespaces<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Let&#8217;s start with one of the simplest but perhaps most significant changes. You can now <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ly a namespace to an entire file via a new syntax option for the <code>namespace<\/code> keyword. The remaining code inside the file will be automatically namespaced, even if it&#8217;s not indented inside a <code>namespace<\/code> block. This works similarly to namespace declarations in PHP.<\/p>\n<p>In C# 9, you needed this code to namespace a class:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">namespace<\/span> Demo <span class=\"br0\">&#123;<\/span>\n&nbsp;\n    <span class=\"kw1\">public<\/span> <span class=\"kw4\">class<\/span> Example <span class=\"br0\">&#123;<\/span>\n    <span class=\"br0\">&#125;<\/span>\n&nbsp;\n<span class=\"br0\">&#125;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>In C# 10, you can use the following instead:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">namespace<\/span> <span class=\"co3\">Demo<\/span><span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"kw1\">public<\/span> <span class=\"kw4\">class<\/span> Example <span class=\"br0\">&#123;<\/span>\n<span class=\"br0\">&#125;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>This saves you some horizontal space in your editor by cutting out a level of indentation. If the file needs to contain multiple classes, you can write them all beginning at column zero &#8211; the <code>namespace<\/code> declaration applies to the whole file.<\/p>\n<h2 id=\"global-usings\"><span class=\"ez-toc-section\" id=\"Global_Usings\"><\/span>Global Usings<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Some namespaces are used very widely across projects. However, you still need to include them manually in each file with a <code>using<\/code> statement.<\/p>\n<p>C# 10 changes this to support a <code>global using<\/code> variant. This will make the referenced namespace accessible across all the files in your project.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\">global <span class=\"kw1\">using<\/span> <span class=\"co3\">System<\/span><span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-gb\/dotnet\/csharp\/language-reference\/keywords\/using-directive#global-modifier\">Global usings<\/a> can be added to any file that will be included in your compilation. They support all the features of standard <code>using<\/code> statements, including the <code>static<\/code> keyword and aliasing with <code>=<\/code>.<\/p>\n<p>Adopting global usings will cut down the number of lines you write but they&#8217;re still best reserved for commonly referenced namespaces that present little chance of naming collisions. Beware that relying on a <code>global using<\/code> could make your code more opaque, as new contributors may not im<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">media<\/a>tely realize how a namespaced resource has been included.<\/p>\n<p>A companion feature to global usings is implicit usings. This automatically creates <code>global using<\/code> statements appropriate for your project&#8217;s type. The capability is turned on by default in the .NET 6 project templates. It can be disabled with the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/aka.ms\/csharp-implicit-usings\"><code>ImplicitUsings<\/code> setting<\/a> in your <code>.csproj<\/code> file.<\/p>\n<h2 id=\"improved-structs\"><span class=\"ez-toc-section\" id=\"Improved_Structs\"><\/span>Improved Structs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Structs have received several enhancements which bring them into closer parity with classes. These include parameterless constructors, field initializers, full support for <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/operators\/with-expression\"><code>with<\/code> expressions<\/a>, and the option of creating record structs:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">public<\/span> record Point<span class=\"br0\">&#040;<\/span><span class=\"kw4\">int<\/span> X, <span class=\"kw4\">int<\/span> Y<span class=\"br0\">&#041;<\/span><span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>This example creates a &#8220;positional&#8221; record struct where the <code>X<\/code> and <code>Y<\/code> constructor parameters become implicit public members. You can also manually define members using the existing syntax:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">public<\/span> record <span class=\"kw4\">struct<\/span> Point <span class=\"br0\">&#123;<\/span>\n    <span class=\"kw1\">public<\/span> <span class=\"kw4\">int<\/span> X <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">get<\/span><span class=\"sy0\">;<\/span> init<span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n    <span class=\"kw1\">public<\/span> <span class=\"kw4\">int<\/span> Y <span class=\"br0\">&#123;<\/span> <span class=\"kw1\">get<\/span><span class=\"sy0\">;<\/span> init<span class=\"sy0\">;<\/span> <span class=\"br0\">&#125;<\/span>\n<span class=\"br0\">&#125;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>A record struct should be used in scenarios where you need to encapsulate some data without attaching custom behaviors as class methods. A record struct offers integrated <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/language-reference\/builtin-types\/record#value-equality\">value equality checks<\/a> and features such as <code>ToString()<\/code>. It can be either mutable or immutable via the <code>readonly<\/code> keyword.<\/p>\n<h2 id=\"lambda-expression-enhancements\"><span class=\"ez-toc-section\" id=\"Lambda_Expression_Enhancements\"><\/span>Lambda Expression Enhancements<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>C# 10 adds several improvements to lambda expressions covering their types and syntax. The objective is to make lambdas more akin to regular methods and local functions. Defining one will now be a more familiar experience.<\/p>\n<p>The concept of a &#8220;natural&#8221; type has been introduced. This lets the compiler infer a lambda&#8217;s type without manually converting it to a delegate or expression. This creates more readable code when assigning a lambda to a variable:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"co1\">\/\/ C# 9<\/span>\nFunc<span class=\"sy0\">&lt;<\/span><span class=\"kw4\">string<\/span>, <span class=\"kw4\">int<\/span><span class=\"sy0\">&gt;<\/span> toInt <span class=\"sy0\">=<\/span> <span class=\"br0\">&#040;<\/span><span class=\"kw4\">string<\/span> s<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"kw4\">int<\/span><span class=\"sy0\">.<\/span><span class=\"me1\">Parse<\/span><span class=\"br0\">&#040;<\/span>s<span class=\"br0\">&#041;<\/span><span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"co1\">\/\/ C# 10<\/span>\n<span class=\"kw1\">var<\/span> toInt <span class=\"sy0\">=<\/span> <span class=\"br0\">&#040;<\/span><span class=\"kw4\">string<\/span> s<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"kw4\">int<\/span><span class=\"sy0\">.<\/span><span class=\"me1\">Parse<\/span><span class=\"br0\">&#040;<\/span>s<span class=\"br0\">&#041;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>The compiler will infer the type of <code>toInt<\/code> as <code>Func&lt;string, int&gt;<\/code> and this will be displayed when you view the code in Visual Studio. Inferences will use <code>Func<\/code>, <code>Action<\/code>, or synthesized delegates.<\/p>\n<p>Natural types will only work when your lambda expression is already fully typed. If you omit parameter types, the compiler won&#8217;t be able to create a compatible type definition.<\/p>\n<p>A related change is support for explicit return types. Like with a regular function, the return type goes before the lambda&#8217;s parameter list:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">var<\/span> toInt <span class=\"sy0\">=<\/span> <span class=\"kw4\">int<\/span> <span class=\"br0\">&#040;<\/span><span class=\"kw4\">string<\/span> s<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"kw4\">int<\/span><span class=\"sy0\">.<\/span><span class=\"me1\">Parse<\/span><span class=\"br0\">&#040;<\/span>s<span class=\"br0\">&#041;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Finally, lambdas can now take attributes in the same way as methods and functions. They&#8217;re positioned at the start of the lambda expression, before the return type and parameter list. You can use attributes to attach extra metadata to your lambdas to facilitate greater introspection and code analysis.<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw1\">var<\/span> toInt <span class=\"sy0\">=<\/span> <span class=\"br0\">&#091;<\/span>DemoAttribute<span class=\"br0\">&#040;<\/span><span class=\"br0\">&#041;<\/span><span class=\"br0\">&#093;<\/span> <span class=\"kw4\">int<\/span> <span class=\"br0\">&#040;<\/span><span class=\"kw4\">string<\/span> s<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=&gt;<\/span> <span class=\"kw4\">int<\/span><span class=\"sy0\">.<\/span><span class=\"me1\">Parse<\/span><span class=\"br0\">&#040;<\/span>s<span class=\"br0\">&#041;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<h2 id=\"versatile-deconstructed-assignments\"><span class=\"ez-toc-section\" id=\"Versatile_Deconstructed_Assignments\"><\/span>Versatile Deconstructed Assignments<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Deconstruction assignments can now both initialize new variables and assign values to existing ones in the same line. Previously you needed to use separate deconstructions for these operations.<\/p>\n<p>In C# 9, this resulted in code that looked like this:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw4\">int<\/span> x <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span>\n<span class=\"kw4\">int<\/span> y <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span>\n<span class=\"br0\">&#040;<\/span>x, y<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=<\/span> point<span class=\"sy0\">;<\/span>\n&nbsp;\n<span class=\"br0\">&#040;<\/span><span class=\"kw4\">int<\/span> z<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=<\/span> point<span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Whereas in C# 10, you can do this:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"kw4\">int<\/span> x <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span>\n<span class=\"kw4\">int<\/span> y <span class=\"sy0\">=<\/span> <span class=\"nu0\">0<\/span><span class=\"sy0\">;<\/span>\n<span class=\"br0\">&#040;<\/span>x, y, <span class=\"kw4\">int<\/span> z<span class=\"br0\">&#041;<\/span> <span class=\"sy0\">=<\/span> point<span class=\"sy0\">;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Now <code>x<\/code>, <code>y<\/code>, and <code>z<\/code> will all be initialized with values using the single deconstruction assignment, reducing repetition in your code.<\/p>\n<h2 id=\"other-changes\"><span class=\"ez-toc-section\" id=\"Other_Changes\"><\/span>Other Changes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>String interpolation has been improved and now works with constant strings too. You need to ensure all the strings used to fill your placeholder holes during interpolation are themselves constant values. More broadly, optimizations to the interpolation process may reduce memory use and increase performance through the use of <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/click.linksynergy.com\/deeplink?id=2QzUaswX1as&amp;mid=24542&amp;u1=csit\/14834&amp;murl=https%3A%2F%2Fdevblogs.microsoft.com%2Fdotnet%2Fwelcome-to-csharp-10\/#interpolated-string-handlers\">dedicated handlers<\/a>.<\/p>\n<p>Property patterns have been simplified to provide more readable access to nested properties. You can now use dot syntax to access nested property values, instead of multiple layers of parentheses:<\/p>\n<div class=\"wp-geshi-highlight-wrap5\">\n<div class=\"wp-geshi-highlight-wrap4\">\n<div class=\"wp-geshi-highlight-wrap3\">\n<div class=\"wp-geshi-highlight-wrap2\">\n<div class=\"wp-geshi-highlight-wrap\">\n<div class=\"wp-geshi-highlight\">\n<div class=\"csharp\">\n<pre class=\"de1\"><span class=\"co1\">\/\/ C# 9<\/span>\n<span class=\"br0\">&#123;<\/span> Train<span class=\"sy0\">:<\/span> <span class=\"br0\">&#123;<\/span>ArrivalTime<span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;10:00&quot;<\/span><span class=\"br0\">&#125;<\/span> <span class=\"br0\">&#125;<\/span>\n&nbsp;\n<span class=\"co1\">\/\/ C# 10<\/span>\n<span class=\"br0\">&#123;<\/span> Train<span class=\"sy0\">.<\/span><span class=\"me1\">ArrivalTime<\/span><span class=\"sy0\">:<\/span> <span class=\"st0\">&quot;10:00&quot;<\/span> <span class=\"br0\">&#125;<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>Elsewhere, compiler optimizations mean you&#8217;ll benefit from fewer false positives during definite assignment and null-state checks. Several C# 9 issues which triggered spurious warnings at compile time have been addressed, resulting in more accurate checks that are better equipped to help you debug issues that actually matter. The problems were linked to using null coalescing expressions and variable comparisons against boolean constants.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>C# 10 adds several new capabilities which will help to make development more straightforward. However, many other new features including the <code>field<\/code> keyword and required properties <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/dotnet\/csharplang\/blob\/main\/meetings\/2021\/LDM-2021-08-30.md\">have been pushed back<\/a> to the next major release. <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/csharp\/whats-new\/csharp-10#generic-attributes\">Generic attributes<\/a> and static abstract members for interfaces made it into 10 but with the preview tag still attached.<\/p>\n<p>You can start using C# 10 today by downloading Visual Studio 2022. The language is also available as part of the standalone <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/click.linksynergy.com\/deeplink?id=2QzUaswX1as&amp;mid=24542&amp;u1=csit\/14834&amp;murl=https%3A%2F%2Fdotnet.microsoft.com%2Fdownload%2Fdotnet%2F6.0\">.NET 6 SDK<\/a> which works across Windows, Mac, and Linux.<\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/14834\/whats-new-in-c-10\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What\u2019s New In C# 10?&#8221; Maria Vonotna\/Shutterstock.com C# 10 was released in November 2021 alongside Visual Studio 2022 and .NET 6. It adds several new features which make it easier and more convenient to work with. Here&#8217;s a tour of some of the most useful additions and how they&#8217;ll enhance your workflow. File-Scoped Namespaces Let&#8217;s&#8230;<\/p>\n","protected":false},"author":1,"featured_media":368426,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/11\/595669bf.jpg","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-368425","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/368425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=368425"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/368425\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/368426"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=368425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=368425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=368425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}