What is Tuple?

Tuple is a type of class which once created, cannot change the type of fields. Tuple is a fixed type ordered sequence. A tuple is an ordered list of elements. In mathematics, an n-tuple is an ordered list of n elements, where n is a non-negative integer, like tuple has stored seven elements and more than seven elements are also possible.


Names,
  • A 2 tuple is called a pair.
  • A 3 tuple is called a tripple.
  • A 4-tuple is called a quadruple.
  • A 5-tuple is called a quintuple.
  • A 6-tuple is called a sextuple.
  • A 7-tuple is called a septuple.

Larger tuples are called n-tuples

Tripple Example:Three items stored in one tuple is called tripple; in this I wrote one example for this tripple,

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace TuppleApplication
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Tuple<string, int, int> tupple = new Tuple<string, int, int>("blue", 1, 2);
  13. if(tupple.Item1=="blue")
  14. {
  15. Console.WriteLine(tupple.Item1);
  16. }
  17. if(tupple.Item2==1)
  18. {
  19. Console.WriteLine(tupple.Item2);
  20. }
  21. if(tupple.Item3==2)
  22. {
  23. Console.WriteLine(tupple.Item3);
  24. }
  25. Console.ReadLine();
  26. }
  27. }
  28. }
A tuple is a immutable.tupple returns mulyiple values.By using create() method we can create tuple,

var tupple=Tupple.create("red",1);