There is not such keyword as
var
in VB.NET, but there is one in C#. And this is not a type. And you did not define type named
var
. Instead of
var
, use appropriate type explicitly.
I don't know your
result
type, so I don't know the type of
item
, but if the type of
result
is a collection or an array, use its element type.
Background:
The type supporting
for each
implements the generic interface
System.Collections.IEnumerable<T>
. The method
System.Collections.IEnumerable.GetEnumerator
returns a value of the type implementing the interface
System.Collections.IEnumerator<code><T>
. This type works with the elements of type
T
, and this is the type of the variable of
for each
loop.
So:
class SomeType { }
class SomeEnumerableType : System.Collections.IEnumerable<SomeType> {
System.Collections.IEnumerator<SomeType> System.Collections.IEnumerable<SomeType>.GetEnumerator() {
}
}
SomeEnumerableType items = new SomeEnumerableType( );
For Each item As SomeType In items
Please see:
http://msdn.microsoft.com/en-us/library/9eekhta0.aspx[
^],
http://msdn.microsoft.com/en-us/library/78dfe2yb.aspx[
^].
—SA