Alex Rivera | Logout

Best Practices: Option Infer

Asked 2009-03-20T20:27:43.707
20

What do you feel are best practices for the use of Option Infer in your projects?

In Visual Studio 2008, Option Infer is a directive that allows the compiler to infer the datatype of a declared variable by looking at what is assigned to it.

This is a key feature in VS2008 and is used extensively with LINQ statements and queries. However, turning on Option Infer may create pitfalls for future maintenance programmers.

Edit
Report

1 Answer

4

Most errors I see have to do with Strict and Explicit, but some occur with Infer. For VB I think this Option Strict On : Option Explicit On : Option Infer Off is the best place to start. It does make writing For Next a bit more cumbersome, but it does mean there will be no question about your intent.

answered 2009-03-21T13:14:18.703

Your Answer