VB.NET equivalent to C# var keyword [duplicate]

Option Infer must be on in order for this to function properly. If so, then omitting the type in VB.NET (Visual Basic 9) will implicitly type the variable.

This is not the same as “Option Strict Off” in previous versions of VB.NET, as the variable is strongly-typed; it’s just done so implicitly (like the C# var) keyword.

Dim foo = "foo"

foo is declared as a String.

Leave a Comment