Tuple.Create method in C#



To create a tuple, use the Tuple.Create method.

Here we have set a tuple with a string and int −

var myTuple = Tuple.Create("marks", 100);

The following is an example that creates a tuple using Tuple.Create and displays the elements in a single line in C# −

Example

 Live Demo

using System;
class Demo {
   static void Main() {
      var myTuple = Tuple.Create("marks", 100);
      Console.WriteLine(myTuple);
   }
}

Output

(marks, 100)
Updated on: 2020-06-22T14:45:08+05:30

120 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements