VB.NET equivalent of C # object initializer of anonymous type

I have no experience with advanced system features like .NET. I can’t find out what type of zz is (what can I write instead of var . Or is var the best choice here?)

string foo = "Bar";
int cool = 2;
var zz = new { foo, cool };    // Watches show this is Anonymous Type

but most importantly, how the equivalent can be achieved in VB.NET code (this is what I really need).

Dim Foo As String = "Bar"
Dim Cool As Integer = 2
Dim zz = {Foo, Cool}    'This is not an equivalent of above, I'm getting an array

I searched for several C # sources, used a code clock and found out what zz looks like , but I can't take the next step.

(The goal of my effort is something like this in VB.NET.)

+4
source share
1

OPTION STRICT, ON, . String + Int32. , Object():

Dim zz As Object() = {Foo, Cool}

, New With:

Dim zz = New With {Foo, Cool}

http://msdn.microsoft.com/en-us/library/bb385125.aspx

+5

Source: https://habr.com/ru/post/1539747/


All Articles