Does Option Strict On add overhead?

S

Showjumper

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?
 
S

Steve C. Orr, MCSD

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.
 
J

John Saunders

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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top