LNG LogoLNG Logo
    • Enterprise App Development
    • Product Architecture Design
    • Data Engineering & Analytics
    • Cloud Consulting Services
    • AI-Enabled Applications
    • Remote Engineering Teams
    • UI/UX Design
    • Data Migration
    • Big Data
    • DevOps Solutions
    • Banking
    • Ecommerce
    • Fintech
    • Healthcare
    • Hospitality
    • Manufacturing
    • Telecom
    • Travel
    • Education
    • Cross-Platform & Web Development
    • Digital Experience Platform
    • Enterprise Technologies
    • Modern Frontend Interface
    • About Us
    • Blog
    • Our Team
    • Careers
    • Success Stories
Let's Talk !

What’s New in C# 10? Features and Enhancements Explained

By: harkiratsingh358May 11, 2022

C# has been around for a while since 2002 to be precise. As we wait for the 20th birthday of this popular programming language, we got its new version as well. C# 10 was released in November 2021 along with the much awaited .Net 6. In this blog we will see some cool features of C# 10.  

Following are some of the features in the new version of C#.

  • Global Using Directive:- After the top level statements feature in C# 9 , that allows us to exclude writing namespace, class and Main method declaration , this global using directive takes it to the next level that even removes the clutter of using statements by making that global in some other file.

In C# 9 you need to import the namespaces of the packages you use in your code in every file wherever required. 

using System;
using System.Linq;
using System.Text.Json;
using CSharp10Features;

var names = new[] { “Amit”, “Aman” };
int count = names.Count();
var serialized = JsonSerializer.Serialize(names);

Console.WriteLine(serialized);

In C# 10 , now you have the flexibility of keeping the namespaces in a single file.

// Moved using statements to a different file with global keyword
var names = new[] { “Amit”, “Aman” };
int count = names.Count();
var serialized = JsonSerializer.Serialize(names);

Console.WriteLine(serialized);

We declare all the using statements in another file and add global keyword to it.

global using System;
global using System.Linq;
global using System.Text.Json;
global using CSharp10Features;

  • File Scoped Namespaces: – Along with minimizing the vertical clutter with global using statements, C# 10 also allows us to reduce the horizontal clutter with file scoped namespaces.

Till C# 9 the namespace declarations used to be block scoped.

namespace CSharp10Features
{
internal class A
{
public string Description { get; set; }
}
internal class B
{
public string Description { get; set; }
}
}

In C# 10 the namespace declarations are now file scoped.

namespace CSharp10Features;

internal class A
{
public string Description { get; set; }
}
internal class B
{
public string Description { get; set; }
}

The compiler provides quick actions to allow us to convert block scoped namespace declaration to file scoped namespaces.

Preview of namespace changes in code
  • Lambda improvements: – C# 10 brings many improvements to the lambda expressions. One of them being natural type lambda expressions

In C# 9 working with lambda expressions required to be bit more complex with more code needed to be written. We needed to explicitly define deligate types.

public void Calculate()
{
Func<int, int, int> Sum = (int x, int y) => x + y;
Console.WriteLine(“Sum is ” + Sum(5, 10));

}

With C# 10, compiler can infer the natural type from the expression at the compile time which means that we can use var.

var Sum = (int x, int y) => x + y;

You can even return explicit type from lambda expression in C# 10 which wasn’t possible earlier.

var NamesList = IList<string>() => new string[] { “Ram”, “Aman”, “Tania” };

If return type wasn’t specified then C# compiler would have assigned it as Func<string[]>

But now it will assign it Func<Ilist<string>>

  • Deconstructor improvements: – In the earlier versions of C# you need to add custom logic to deconstruct an object of a type , but now there is a deconstruct method available on reference types that makes the task easy.

Before C# 10 this is how we used to break an object

var person = new Person
{
Name = “Harkirat Singh”,
DOB = new DateOnly(1992, 08, 30),
Address = “Chandigarh”,
Qualification = “Btech”,
PhoneNumber = “123456785”
};

var name=person.Name;
var dob=person.DOB;
var address=person.Address;
var qual=person.Qualification;
var phone=person.PhoneNumber;

Deconstructors are the real game changers in C# 10 and were much awaited since its inception in the javascript world. Also now assignment and declaration is possible in the same deconstruction. Tuples don’t require Deconstruct method

public (string name, DateOnly dob) GetPerson()
{
var person = (Name: “Harkirat Singh”, DOB: new DateOnly(1992, 08, 30));
(string name, DateOnly dob) = person;
return person;
}

But other types such as classes do require Deconstruct method for deconstruction.

public void Deconstruct(out string name, out DateOnly dob, out string qual, out string phone)
{
name = Name;
dob = DOB;
qual = Qualification;
phone = PhoneNumber;
}

public Person GetDetails()
{
var person = new Person
{
Name = “Harkirat Singh”,
DOB = new DateOnly(1992, 08, 30),
Address = “Chandigarh”,
Qualification = “Btech”,
PhoneNumber = “123456785”
};
(string firstName, DateOnly dob, string qualifications, string phoneNumber) = person;

//Can console write any of the above variables

return person;
}

  • Extended property patterns: – Sometimes we need nested properties in our code i.e property of a property. Using pattern matching on these values is possible in previous versions of the C# as well, but code looks a bit weird.

if (person is { Name: { Length: > 10 } })
{
Console.WriteLine(“You should use a nickname”);
}

C# 10 provides dot operator to solve this problem with much cleaner code.

if (person is { Name.Length: > 10 })
{
Console.WriteLine(“You should use a nickname”);
}

Please check MS docs for all list of features.

Stay tuned for more .Net 6 updates

Happy coding

ヘ( ^o^)ノ\(^_^ )

Two CMSs, One Website: Managing Routing During WordPress to Sitecore MigrationJune 17, 2026Mastering Identity Resolution in Sitecore CDP: Anonymous to Known VisitorsMay 25, 2026

Let's Innovate, Collaborate, Build Your Product Together!

We turn your unique ideas into exceptional results. Contact us to
scale your tech capacity and accelerate business growth.

Let's Talk!
Where We Are

Our Global Presence

Delivering world-class digital solutions from three strategic locations across the globe.

South AfricaSouth Africa
ZACape Town

4th Floor, Mutual Park, Pinelands, Capetown, South Africa - 7405.

UAEUAE
AEDubai

FZCO 421, Dubai Commercity, Dubai, United Arab Emirates.

IndiaIndia
INAmritsar

SCO 6, Floor - 5, Dua Square, Ranjit Avenue, Block - B, Amritsar, Punjab, India - 143002

Logo

AI-Fuelled software agency, helping business professionals to thrive. Trusted by global leaders.

Company

  • About Us
  • Blog
  • Our Term
  • Careers
  • Success Stories

Services

  • AI-Enabled Applications
  • Big Data
  • Cloud Consulting Services
  • Data Engineering & Analytics
  • Data Migration
  • DevOps Solutions
  • Enterprise Application Development
  • Product Architecture Design
  • Remote Engineering Teams
  • UI/UX Design

Industries

  • Banking
  • Ecommerce
  • Fintech
  • Healthcare
  • Hospitality
  • Manufacturing
  • Telecom
  • Travel & Transport
  • Education

Technologies

  • Cross-Platform and Web Development
  • Digital Experience Platform
  • Enterprise Technologies
  • Modern Frontend Interface
Logo

AI-Fuelled software agency, helping business professionals to thrive. Trusted by global leaders.

Company
  • About Us
  • Blog
  • Our Term
  • Careers
  • Success Stories
Services
  • AI-Enabled Applications
  • Big Data
  • Cloud Consulting Services
  • Data Engineering & Analytics
  • Data Migration
  • DevOps Solutions
  • Enterprise Application Development
  • Product Architecture Design
  • Remote Engineering Teams
  • UI/UX Design
Industries
  • Banking
  • Ecommerce
  • Fintech
  • Healthcare
  • Hospitality
  • Manufacturing
  • Telecom
  • Travel & Transport
  • Education
Technologies
  • Cross-Platform and Web Development
  • Digital Experience Platform
  • Enterprise Technologies
  • Modern Frontend Interface

Copyright © 2026 L&G Consultancy. All Rights Reserved.
Privacy PolicyTerms and Conditions
Company Image