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 “WorkbookNotSupported – The file you selected cannot be opened because it...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SpecifiedRangeNotFound – The requested range does not exist in the sheet.”...
  • .NET
  • December 17, 2022
In this post, you’ll learn about the error message “SheetRangeMismatch – The sheet provided as the sheet argument is not...
  • .NET
  • December 17, 2022