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: 22-Jun-2020

58 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements