Is there a way to start with a non-zero index when using a for each loop in vb?
I got an error "The input string was not in the correct format" when trying:
For Each segment As String in p
If not p(0) Then
You can use the LINQ Enumerable.Skip method to reduce your list before repeating it:
For Each segment As String in p.Skip(1) ... Next
I think your misunderstanding of the difference between for eachand for.
for each
for
for eachwill go through each element of the array forwill go through the indices of the array
for i = 0 to p.size //change 0 to the index you want to start p(i) ... next
,
for each segment as string in p.Skip(1) . . . . next
5 . . . in p.Skip(5)
. . . in p.Skip(5)
Skip, lambda, , .
The lambda will list as a foreach loop, but it will also call the delegate passed to it as an argument to check the condition.
Assuming it phas an index, for example, ArrayorIList
p
Array
IList
For i As Integer = 1 To p.Count - 1 p(i) Next
It is assumed that you are using standard Option Base 0
Option Base 0