我可以在项目/解决方案级别设置 Option Explicit 和 Option Strict 吗? [英] Can I set Option Explicit and Option Strict on a Project/Solution level?

查看:23
本文介绍了我可以在项目/解决方案级别设置 Option Explicit 和 Option Strict 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很喜欢 VB.NET 提供的编码速度,但我不喜欢忘记声明变量类型、函数返回类型等的可能性,这就是我在每个类中使用的原因:

选项显式开启选项严格

有没有办法在项目/解决方案级别定义这两个选项?
在每个类中复制这两个选项真的很乏味...
我们在 .NET 4 客户端配置文件中使用 Visual Studio 2010 进行编码.

解决方案

,您可以在项目的属性中为整个项目设置这些选项:

  1. 在解决方案资源管理器中右键单击您的项目,然后从上下文菜单中选择属性".
  2. 点击左侧列表中的编译"选项卡.
  3. 根据需要设置组合框的值.

   


您还可以选择在 Visual Studio 选项中全局指定这些设置(尽管这只会影响项目,而不影响现有项目):

  1. 在 Visual Studio 环境中,单击工具"菜单并选择选项".
  2. 在对话框左侧的树视图中展开项目和解决方案"项.
  3. 选择VB 默认值"项.
  4. 根据需要设置默认项目设置".

   

I really like the coding speed that VB.NET provides, but I don't like the possibility to forget to declare variable types, return types of functions, etc. and that is why in each class I use:

Option Explicit On  
Option Strict On

Is there a way to define those two options on the project/solution level?
It is really tedious to copy those two options in each class...
We code with Visual Studio 2010 in .NET 4 Client Profile.

解决方案

Yes, you can set these options for the entire project in your project's Properties:

  1. Right-click on your project in the Solution Explorer, and select "Properties" from the context menu.
  2. Click on the "Compile" tab in the list on the left-hand side.
  3. Set the values of the comboboxes as desired.

   


You could also choose to specify these settings globally in the Visual Studio options (although this will only affect new projects, not existing ones):

  1. In the Visual Studio environment, click on the "Tools" menu and select "Options".
  2. Expand the "Projects and Solutions" item in the treeview on the left-hand side of the dialog.
  3. Select the "VB Defaults" item.
  4. Set your "Default project settings" as desired.

   

这篇关于我可以在项目/解决方案级别设置 Option Explicit 和 Option Strict 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆