Groups | Blog | Home
all groups > asp.net > july 2003 >

asp.net : Does Option Strict On add overhead?


Steve C. Orr, MCSD
7/30/2003 9:11:47 PM
The CStr conversion happens whether you have Option Strict on or not.
So no there isn't any overhead.
The main difference is that with Option Strict On you are forced to do such
conversions explicity instead of relying on VB to do them automatically for
you.
While this requires a bit of extra work, it is considered to be well worth
it to help prevent unexpected runtime errors.
These kinds of bugs can be notoriously difficult to flush out and can be
very expensive to fix if they are discovered after an app is deployed. This
is why most good developers will tell you to always turn Option Strict on.

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


[quoted text, click to view]

Showjumper
7/30/2003 11:56:26 PM
By turning Option Strict on, is there extra overhead? For example w/o it on
the following doesnt get flagged:
validxhtml.Attributes.Add("height", 22) but with it on the 22 is underlined
and the message is "Option Strict On disallows implicit conversions from
'Integer' to 'String'.". I then use validxhtml.Attributes.Add("height",
cstr(22)) and the blue squiggel goes away with strict on. By using cstr is
there extra overhead created?

John Saunders
7/31/2003 6:34:19 AM
Option Strict On causes no overhead.

In fact, it reduces the overhead caused by developers wondering why their
code didn't work, since it compiled ok.

In your example, why not use:

validxhtml.Attributes.Add("height", "22")

--
John Saunders
Internet Engineer
john.saunders@surfcontrol.com

[quoted text, click to view]

AddThis Social Bookmark Button