Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET vs C#: Anonymous types and intellisense

How come when do this 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 get no intellisene on .Name?

like image 290
oscilatingcretin Avatar asked Apr 05 '13 12:04

oscilatingcretin


People also ask

Which is better VB.NET or C#?

When you will go for a job in Programming then C# will be the better choice. If you first want to learn then VB could be the better choice - it depends on what is better readable for you. In both cases : what you have to learn is not the programming-language - what you have to learn is the use of the .

Is VB.NET the same as C#?

Though C# and VB.NET are syntactically very different, that is where the differences mostly end. Microsoft developed both of these languages to be part of the same . NET Framework development platform. They are both developed, managed, and supported by the same language development team at Microsoft.

Which is easier to learn VB.NET or C#?

1. VB.NET uses implicit casting and makes it easier to code whereas in C# there are lot of casting and conversions needs to be done for the same lines of code. Another aspect to be noted is that the identifiers in VB.NET are not case-sensitive. 2.


2 Answers

This sounds a momentary situation to me. Because when I try,

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

It shows

enter image description here

Consider also Option Infer Statement

Enables the use of local type inference in declaring variables.

like image 82
Soner Gönül Avatar answered Sep 21 '22 11:09

Soner Gönül


Answering my own question here. In VB.NET, you have 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't because this question already has an answer and 2) I am sure this will be helpful to others anyway.

Happy inferring.

like image 26
oscilatingcretin Avatar answered Sep 21 '22 11:09

oscilatingcretin