Saturday, 24 December 2016

Tuple In C#

eg.  Following example create a 3 items  of tuples using the special constructor syntax.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tuples
{
    class Program
    {
        static void Main(string[] args)
        {
           
            Tuple<string, int, bool> tuple = new Tuple<string, int, bool>("James", 5, true);
            // Access tuple properties.
            if (tuple.Item1 =="James")
            {
                Console.WriteLine(tuple.Item1);
                Console.ReadLine();
            }
            if (tuple.Item2 ==2)
            {
                Console.WriteLine(tuple.Item2);
            }
            if (tuple.Item3)
            {
                Console.WriteLine(tuple.Item3);
            }

        }
    }
}

OutPut:

Jamesh
True




No comments:

Post a Comment