C#’s var keyword equivalent in VB.NET

This article will explain the keyword “Dim” which is the C#’s var keyword equivalent in VB.NET .

In one of my previous blog posts , I explained about 5 things that you cannot do with a Local Type Inference in C# which explained about the use of the Var keyword in C#.

If you are looking for a var keyword in VB.NET , this blog post is for you .

The VB.NET has the keyword Dim which works similar to the var keyword in C3 for local type inference . In this case , you need to enable the Option Infer and Option Infer for the local type inference to work correctly.

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

Dim s = "Welcome to Ginktage.com"

MessageBox.Show(s.GetType().ToString())

End Sub

End Class