Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the VB.NET equivalent of the C# “var” keyword?

Tags:

c#

.net

vb.net

E.g. how do I get VB.NET to statically type a local variable to be the static type of the expression on the right had side of the assignment?

like image 694
Ian Ringrose Avatar asked Dec 22 '09 14:12

Ian Ringrose


People also ask

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.

Is VB.NET similar to C++?

You are right, C++ and VB are two completely different languages and have quite a few fundamental differences (managed vs. unmanaged being a major one that comes to mind...).

What is equivalent to C#?

It is enharmonically equivalent to D-flat major. Its key signature has seven sharps.


1 Answers

Like this:

Dim myVar = 3

You'll also need

Option Infer On

(At the top of the file or in project settings)

See "Local Type Inference"

like image 152
SLaks Avatar answered Sep 24 '22 02:09

SLaks