VB.NET vs C #: anonymous types and intellisense

How does this happen in C # ...

var x = new { Name = "aaa" };

... I can get intellisense on .Name, but when I do this in VB.NET ...

Dim x = New With {.Name = "aaa"}

... I do not get intellisene on .Name?

+5
source share
2 answers

Answering my own question here. In VB.NET you need to use the module level option infer on.

I was going to just delete this question after I figured out the problem, but 1) I can not, because this question already has an answer, and 2) I am sure that it will still be useful to others.

Happy conclusion.

+2
source

It sounds instant to me. Because when I try

Dim x = New With {.Name = "aaa"}

He shows

enter image description here

Consider also Option Infer Statement

.

+6

All Articles