Home > database >  How can I add items to named Tuple
How can I add items to named Tuple

Time:10-08

I have the following named list of Tuple

var tupleList = new List<(string SureName, string LastName, int Age)>();

How can I add items to that list using tupleList.Add ?

CodePudding user response:

var tupleList = new List<(string SureName, string LastName, int Age)>();
tupleList.Add(("a", "b", 3));

enter image description here

As you can see it demanded an item at the end of add, which seems to be optional and the reason for the double brackets.

CodePudding user response:

var tupleList = new List<Tuple<string, string, int>>();
tupleList.Add(new Tuple<string, string, int>("Nicolas", "Smith", 32));
  • Related