Enables the use of local type inference in variable declarations.

/optioninfer[+ | -]


  • + | -
    Optional. Specify /optioninfer+ to enable local type inference, or /optioninfer- to block it. The /optioninfer option, with no value specified, is the same as /optioninfer+. The default value when the /optioninfer switch is not present is also /optioninfer+. The default value is set in the Vbc.rsp response file.


You can use the /noconfig option to retain the compiler's internal defaults instead of those specified in vbc.rsp. The compiler default for this option is /optioninfer-.


To set /optioninfer in the Visual Studio integrated development environment

  1. Select a project in Solution Explorer.

  2. On the Project menu, click the Properties link for the selected project to access the Project Designer. For more information, see Introduction to the Project Designer.

  3. On the Compile tab, modify the value in the Option Infer box.

To set /optioninfer programmatically


The following code compiles test.vb with local type inference enabled.

vbc /optioninfer+ test.vb

See Also


Local Type Inference





Sample Compilation Command Lines

Option Infer Statement

Visual Basic Defaults, Projects, Options Dialog Box

Compile Page, Project Designer (Visual Basic)


Other Resources

Visual Basic Compiler

Building from the Command Line (Visual Basic)