C# program to access the generic Tuple list using Statement Lambda

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 305
The below program will do so

//Create Generic Tuple Collection
List<Tuple<string, int, List<string>>> studentTupleInstances = new List<Tuple<string, int, List<string>>>();

//Add the first record
studentTupleInstances.Add(new Tuple<string, int,
List<string>>(
"Rajlakshmi Biswas", 4,
new List<string> { "Mathematics","English", "Science and Social Science","Hindi"}));

//Add the second record
studentTupleInstances.Add(new Tuple<string, int,
List<string>>(
"Niladri Biswas"
, 36
, new List<string> { "Mathematics","English","Computer Science","History","Physics"}));

//Add the third record
studentTupleInstances.Add(new Tuple<string, int, List<string>>(
"Arina Biswas"
, 26
, new List<string> { "Mathematics","English","Accountancy","Finance"}));


//Access the records using Lambda
studentTupleInstances
.ForEach
(student =>

{
Console.WriteLine("Student Name : " + student.Item1);
Console.WriteLine("Student Age : " + student.Item2);

student.Item3
.ForEach
(
subject=> Console.WriteLine("Is reading : " + subject)
);

Console.WriteLine("------------------------------------------");
}
);

Comments or Responses

Login to post response