Enforce datatypes passed to methods (Option Strict)

后端 未结 1 807
情歌与酒
情歌与酒 2020-12-12 05:54

I am using VS2005 to maintain some vb.net code. I am preparing to update to newer toolsets and am doing code cleanup first.

I am cleaning up all the compile error m

相关标签:
1条回答
  • 2020-12-12 06:17

    Selectively Turn on Option Strict

    Add to the top of the code file:

    Option Strict On
    

    Since this will enforce the option only in those files, this method is not recommended on an ongoing basis because it requires you to remember to do so for each file.

    Project Wide

    Open Project Properties (Project Menu - Properties among others). On the Compile Tab set the Option Strict drop down to On. You can also demote some conditions from an error to a warning or ignore that condition.

    This too can be forgotten.

    Visual Studio Default (recommended)

    You can make Option Strict On the default setting for all new projects, so you don't have to remember to do so at any level:

    Tools Menu -> Projects and Solutions -> VB Defaults

    This wont affect a project already in the works - use #2 for that.

    0 讨论(0)
提交回复
热议问题