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"


End Sub

End Class


If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

No Responses

Leave a Reply to The Daily Six Pack: February 18, 2013 – Dirk Strauss' Tech Blog Cancel reply


Interesting BlogPosts to read

How to add entries to ResourceDirectory in WPF using C# ?
Below is a sample code snippet demonstrating how the entries can be added to the ResourceDirectory i...
Replacing Multiple spaces with single space in C#
Are you looking at an sample demonstrating the usage of the regular expression to replace multiple s...
How to rename a file in C# ?
Want to rename a file using .NET Framework and C# ? , below is a sample code snippet that illustrate...