Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Convert a ValueTuple to a Tuple in C#
With C#, we can easily convert a ValueTuple to a Tuple using ToTuple() method.
Note − Add System.ValueTuple package to run ValueTuple program.
Let’s see how to add it −
- Go to your project
- Right click on the project in the solution explorer
- Select “Manage NuGet Packages”
- You will reach the NuGet Package Manager.
- Now, click the Browse tab and find “ValueTuple”
- Finally, add System.ValueTuple package
Example
using System;
class Program {
static void Main() {
var val = (5, 50, 500, 5000);
//Add System.ValueTuple package to run this program
// ValueTuple
Console.WriteLine(“ValueTuple: ” val);
// Tuple
Tuple<int, int, int, int> myTuple = val.ToTuple();
Console.WriteLine(“Tuple: ”+myTuple);
}
}
Output
ValueTuple: (5, 50, 500, 5000) Tuple: (5, 50, 500, 5000)
Advertisements
