Recently, Microsoft announced various new features in C# 7.0 with Visual Studio 2017. In C# 7.0, some new feature of tuples are enhanced with Visual Studio 2017. Tuples aren’t new in C# or.NET. They were first introduced as a part of.NET Framework 4.0. This useful feature of the tuple is all about returning multiple value without having:
- A class and list<> of the class.
- Array, observableCollection, ArrayList or Dictionary.
- A series of ref or out parameters.
It is similar to the code snippet given below.
- public (string name, string dept, int id) GetData()
- {
- return ("Avnish", "R&D", 001);
- }
Before C# 7.0, the use of tuple is given below.
- public Tuple<string, string, int> GetData2()
- {
- return new Tuple<string, string, int>("Rakesh", "Marketing", 002);
- }
Let's create a console project for demo.
Step 1
Create a new 'Console App' in Visual Studio 2017 RC or Visual Studio 2017.

Step 2
Go to add a NuGet package. By right click to "References" in Solution Explorer, click on "Manage NuGet Package". Now, search for "System.ValueTuple" and install such package.

Step 3
For use of tuples, add the code given below in Program.cs.
Create a new 'Console App' in Visual Studio 2017 RC or Visual Studio 2017.

Step 2
Go to add a NuGet package. By right click to "References" in Solution Explorer, click on "Manage NuGet Package". Now, search for "System.ValueTuple" and install such package.

Step 3
For use of tuples, add the code given below in Program.cs.


Avnish KumarPosted Mar 21, 2018, 4:20 AM
Thanks for your valuable feedback...
Avnish KumarPosted Mar 21, 2018, 4:18 AM
If you target a Framework that doesn’t yet include those types, you can instead pick them up from NuGet
Archana SainiPosted Mar 21, 2018, 4:08 AM
great information . Thanks :)
Md GhousePosted Jan 31, 2017, 11:56 PM
Good work u did Freind .... NiceExplination