Your code would not even compile with OPTION STRICT
set to ON which is highly recommended. No type can be derived from String
+ Int32
. It would compile if you want an Object()
:
Dim zz As Object() = {Foo, Cool}
But you want to create an anonymous type, use New With
:
Dim zz = New With {Foo, Cool}
http://msdn.microsoft.com/en-us/library/bb385125.aspx
With .NET 4.7 and Visual Basic 2017 you can also use ValueTuples
with names:
Dim zz = (FooName:=foo, CoolName:=cool)
Now you can access the tuple items by name:
int cool = zz.CoolName;