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
(string name, string email) = var employee;
Or
string name;
string email;
(name, email) = employee;
In C# 10
string name;
(name, string email) = employee;
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.
Old format
namespace ConsoleAppcore
{
internal class User
{
}
}
New format for C# 10
namespace ConsoleAppcore;
internal class User
{
}
No comments:
Post a Comment