1.

How to set 5-item tuple in C#?

Answer»

To set 5-item tuple in C#, set it like this:

var t = new Tuple<string, string[], int, int, int>("laptop",      new string[] { "memoy CARD", "pen drive" },      30,      40,      50);

Above, the tuple has string, string array, and three integer tuples. Therefore, MAKING it a 5-item tuple.

The following is an example:

using System; class Example {   STATIC void Main() {      var t = new Tuple<string, string[], int, int, int>("laptop",      new string[] { "memoy card", "pen drive" },      30,      40,      50);      Console.WriteLine("Tuple Item 1 = "+t.Item1);      Console.WriteLine("Tuple Item 4 = "+t.Item4);      Console.WriteLine("Tuple Item 5 = "+t.Item5);   } }

The output:

Tuple Item 1 = laptop Tuple Item 4 = 40 Tuple Item 5 = 50


Discussion

No Comment Found