Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to iterate through a strongly-typed generic List<T>?

What is the best way to iterate through a strongly-typed generic List in C#.NET and VB.NET?

like image 351
billmaya Avatar asked Aug 18 '08 20:08

billmaya


1 Answers

For C#:

foreach(ObjectType objectItem in objectTypeList)
{
    // ...do some stuff
}

Answer for VB.NET from Purple Ant:

For Each objectItem as ObjectType in objectTypeList
    'Do some stuff '
Next
like image 189
mbillard Avatar answered Sep 28 '22 07:09

mbillard