I would like to use VB9 but am not sure what syntax to use to say that I want a variable to be statically typed as in C#’s:
var foo = new Whatever();
In previous versions of VB:
Dim foo = New Whatever()
created a dynamically typed variable.
Is there a way to get static typing without actually writing the type in VB9?
Yes, you can control this behaviour through the
Optiondirectives at the beginning of each file or in the project settings:It’s best-practice to set
Option Strict Onas the default for all your projects (can be done in the options dialog). This guarantees the same typing behaviour as in C#. Then, if you need dynamic typing, you can disable the setting selectively on a per-file basis by using the directive mentioned above.