Reputation: 53
Dim myList As New List(Of Integer)(New Integer() {1001, 1006, 1011, 1016, 1021, 1026, 1031, 1036, 1041, 1046, 1051, 1056, 1061, 1066, 1071})
How can I reduce the code above?
Upvotes: 0
Views: 1489
Reputation: 216273
The initialization of the first list could be done in this way
Dim init As Integer = 1001
Dim myList As IEnumerable(Of Integer) = Enumerable.Range(start:=0, count:=15).
Select(Function(x) init + (x * 5))
The creation of the string result could be done with String.Join
Dim result = String.Join(Environment.NewLine, myList)
Console.WriteLine(result)
Upvotes: 3