Reputation:
I want following code in two lines.
Dim myList As New List(Of Integer)(New Integer() {30, 31, 32, 33, 34, 35})
I have tried following codes but it doesnt work.
Could you please repair following code?
Dim myList As New List(Of Integer)
MessageBox.Show("Hello")
myList = (New Integer() {30, 31, 32, 33, 34, 35})
So, how can I declare a list in separate line?
Upvotes: 0
Views: 92
Reputation: 3007
Use this
Dim myList As New List(Of Integer)
myList.AddRange({30, 31, 32, 33, 34 , 35})
Or
Dim myList As List(Of Integer)
MessageBox.Show("Hello")
myList = New List(Of Integer) From {30, 31, 32, 33, 34, 35}
Upvotes: 3