如何在vb.net中使用for循环,例如
dim start as integer
Dim customers as New List(Of Customers)
Customers=dataAcess.GetCustomers()
For each start=500 in Customers.count
'Do something here'
Next
我想为每500个客户处理一些数据。
发布于 2018-08-07 15:22:04
这样做吧:
Dim customers As List(Of Customer) = dataAccess.GetCustomers()
然后,对于循环,需要一个普通的“for”循环,而不是“每个循环”。不要忘记在列表结束之前停止:
For i As Integer = 500 To Customers.Count -1
'do something with Customers(i) here
Next i
如果你使用的是VisualStudio 2008,还可以这样编写它:
For each item As Customer in Customers.Skip(500)
'Do something with "item" here
Next
发布于 2018-08-07 15:54:39
尝试以下方法
For Each current In customers
'' // Do something here
Console.WriteLine(current.Name)
Next
https://stackoverflow.com/questions/-100000521
复制相似问题