Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent of var in Visual Basic to use in For Each Loop

Tags:

c#

vb.net

I need to run some code in Visual Basic that is the equivalent to this in C#:

for(var item in removeRows)
{
   two.ImportRow(item);
}

I know that the closest you can come to declaring "var" in VB is basically

Dim something =

However, how would you do this in a foreach loop?

like image 566
NealR Avatar asked Dec 12 '22 22:12

NealR


1 Answers

You would just use:

For Each item In removeRows
    two.ImportRow(item)
Next

The As datatype specification in VB is optional. See For Each documentation for details.

like image 71
Reed Copsey Avatar answered Dec 14 '22 12:12

Reed Copsey