July 2015
Intermediate to advanced
1300 pages
87h 27m
English
Local type inference is a language feature that allows you to omit specifying the data type of a local variable even if Option Strict is set to On. The Visual Basic compiler can deduce (infer) the most appropriate data type depending on the variable’s usage. The easiest way to understand and hopefully appreciate local type inference is to provide a code example. Consider the following code and pay attention to the comments:
Sub Main() 'The compiler infers String Dim oneString = "Hello Visual Basic 2015!" 'The compiler infers Integer Dim oneInt = 324 'The compiler infers Double Dim oneDbl = 123.456 'The compiler infers Boolean Dim oneBool = TrueEnd Sub
As you can see, ...