VB.net program to access the generic Tuple list using Foreach Loop

Rajnilari2015
Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 557
The below program will do so

'Create Generic Tuple Collection
Dim studentTupleInstances As New List(Of Tuple(Of String, Integer, List(Of String)))()

'Add the first record
studentTupleInstances.Add(New Tuple(Of String, Integer, List(Of String))("Rajlakshmi Biswas", 4, New List(Of String)() From { _
"Mathematics", _
"English", _
"Science and Social Science", _
"Hindi" _
}))

'Add the second record
studentTupleInstances.Add(New Tuple(Of String, Integer, List(Of String))("Niladri Biswas", 36, New List(Of String)() From { _
"Mathematics", _
"English", _
"Computer Science", _
"History", _
"Physics" _
}))

'Add the third record
studentTupleInstances.Add(New Tuple(Of String, Integer, List(Of String))("Arina Biswas", 26, New List(Of String)() From { _
"Mathematics", _
"English", _
"Accountancy", _
"Finance" _
}))


'Access the records using Foreach Loop
For Each student As var In studentTupleInstances
Console.WriteLine("Student Name : " + student.Item1)
Console.WriteLine("Student Age : " + student.Item2)

For Each subject As var In student.Item3
Console.WriteLine("Is reading : " + subject)
Next

Console.WriteLine("------------------------------------------")
Next

Comments or Responses

Login to post response