In C# (7+) I can declare (Better naming in Tuple classes than "Item1", "Item2")
var myList = new List<(int first, int second)>();
and later on refer to items:
var a = myList[0].second;
Is there an equivalent syntax in VB.NET?
Edit From Andrew Morton's answer, the equivalent syntax is:
Dim myList = New List(Of (first As Integer, second As Integer))
Dim a = myList(0).second
Yes, see Tuples (Visual Basic).
Dim q As New List(Of (EventDate As Date, Name As String, IsHoliday As Boolean))
q.Add((EventDate:=#2019-01-01#, Name:="New Year's Day", IsHoliday:=True))
q.Add((New DateTime(2019, 6, 21), "Summer solstice", False))
Console.WriteLine(q(0).Name) ''outputs "New Year's Day"
Console.WriteLine(q(1).IsHoliday) ''outputs False
(Visual Studio 2017 and later.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With