Does Option Strict On add overhead?

Discussion in 'ASP .Net' started by Showjumper, Jul 31, 2003.

  1. Showjumper

    Showjumper Guest

    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?
    Showjumper, Jul 31, 2003
    1. Advertisements

  2. 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
    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.
    Steve C. Orr, MCSD, Jul 31, 2003
    1. Advertisements

  3. 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, Jul 31, 2003
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.