Connecting Tech Pros Worldwide Forums | Help | Site Map

vb.net: Use Strict

Newbie
 
Join Date: Oct 2008
Posts: 2
#1: Oct 15 '08
what are the advantages of using option strict in vb.net

insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#2: Oct 15 '08

re: vb.net: Use Strict


From MSDN
Quote:
Because Option Strict On provides strong typing, prevents unintended type conversions with data loss, disallows late binding, and improves performance, its use is strongly recommended.
Strong typing is a great advantage to programming, because it forces you to explicitly cast your values. It allows for less mistakes. Sure it's easier to just, for example, be able to assign a Double's value to an Integer. But you lose data that way, and it's good for the compiler to make sure that is what you intended. An explicit cast guarantees that you wanted to make that cast, rather than assuming.

The reason that it is turned off by default is to import VB 6 projects which didn't have that option. If you aren't using legacy code, you should use option Strict.
Reply