VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/getting-the-string-that-represent-the-value-of-the-tuple-2-instance-in-c-csharp/

⇱ Getting the String that Represent the Value of the Tuple<T1,T2> Instance in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Getting the String that Represent the Value of the Tuple<T1,T2> Instance in C#

Last Updated : 12 Jul, 2025
A tuple is a data structure that gives you the easiest way to represent a data set. You can also get a string that represents a tuple object by using the ToString Method. This method returns a string that will represent the Tuple<T1, T2> object. The string represented by this method is in the form of (Item1, Item2) here Item1 and Item2 represent the values of Item1 and Item2 properties. And it will represent a String.Empty if any property contains a null value. Syntax:
public override string ToString ();
Return Type: The return type of this method is System.String. So, it will return a string that represents Tuple<T1, T2> object. Example 1:
Output:
Tuple 1: (Rohit)
Tuple 2: (Sheema, Riya)
Example 2:
Output:
NTuple 1: (Sumit, (Bongo, Bella, Binu))
NTuple 2: (Boond, Cinki, Chimmy, (Karan, Micky))
NTuple 3: (34.9, 78.7, (12.2, 34.5, 5.6, 0.78))
NTuple 4: (2, 4, 6, 8, 5, (10, 20, 30, 40, 50))
Comment
Article Tags:
Article Tags:

Explore