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

 

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the error message “FileOpenAccessDenied – You do not have permissions to open this file...
  • .NET
  • December 3, 2024
You might have had a situation where your code once worked fine in ASP.NET application but now throws the below...
  • .NET
  • December 3, 2024
C# uses the flower bracket “{” and “}” to identify the block or scope of the function or program ....
  • .NET
  • December 3, 2024