Home > DeveloperSection > Forums > How to use Tuple in C#
Ankit Singh

Total Post:341

Posted on    November-27-2015 9:53 PM

 C# C#  .NET 

 1 Reply(s)
 322  View(s)
Rate this:
I want to use Tuple in C# Please help me.

aditya kumar Patel

Total Post:250

Posted on    November-27-2015 10:01 PM

C# 4.0 included a new feature called Tuple. A tuple is a data structure that has a specific number and sequence of elements.
Tuple can be used in several ways. Let’s see, how tuple can be used to return multiple values from a method.

using System;
namespace TupleApplication
    class Mainprogram
        static void Main(string[] args)
            ClassTuple objTuple = new ClassTuple();
            var tuple = objTuple.Operations("Aditya","Singh","Patel","7798930674");
            Console.WriteLine("FirstName:{0}, MiddleName:{1}, LastName :{2}, ContactNo:{3}", tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4);
    class ClassTuple
        public Tuple<string, string, string, string> Operations(string fname, string Mname, string Lname, string Contact)
            return Tuple.Create(fname, Mname, Lname,Contact);

Don't want to miss updates? Please click the below button!

Follow MindStick