Tutorial by Examples

Enables the use of local type inference in declaring variables. What is type inference? You can declare local variables without explicitly stating a data type. The compiler infers the data type of a variable from the type of its initialization expression. Option Infer On: Dim aString = "12...
Document level It is on by default, but you can set it by placing Option Infer On|Off at the top of the code file. The option will apply to the whole document. Project level You can switch it on/off via the menu in Visual Studio: Project > [Project] Properties > Compile Tab > Option i...
Basically you can use type inference whenever it is possible. However, be careful when combining Option Infer Off and Option Strict Off, as this can lead to undesired run-time behavior: Dim someVar = 5 someVar.GetType.ToString() '--> System.Int32 someVar = "abc" someVar.GetType.To...

Page 1 of 1