VB.Net - Option Infer

This is switched on by default.
This is used extensively with LINQ statements
This enables the user of local type inference when declaring variables.
When this is On, you can declare local variables without explicitly stating their data type.


New to VB in Visual Studio 2008
The default is on.
If you have Option Explicit switched off then whether a variable has the old behaviour or new is determined by this setting ???


Turning Option Infer On allows old VB6 code full of variants to compile and run.
To set Option Infer in a file type type Option Infer On at the top of the file, before any source code
If this value conflicts with the setting in the IDE then the value in the file has precedence.
The compiler infers the data type for a variable when it is initialised.



Project Settings

Right click on your project and select "Properties"
Display the Compile tab
SS


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext