加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

.net – Option Strict和Option Explicit有什么作用?

发布时间:2020-12-16 22:35:21 所属栏目:大数据 来源:网络整理
导读:我看到这个帖子: Typos… Just use option strict and explicit please.. during one software development project,which I was on as a consultant,they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spe
我看到这个帖子:

Typos… Just use option strict and explicit please.. during one software development project,which I was on as a consultant,they were getting ridiculous amounts of errors everywhere… turned out the developer couldn’t spell and would declare variables with incorrect spelling.. no big deal,until you use the correct spelling when you’re assigning a value to it… and you had option explicit off. Ouch to them…”

什么是选项严格和选项显式?我已经google了它,但不能得到的想法(因为大多数是Visual Basic,我做PHP)。

Option Explicit意味着必须声明所有变量。见 here.没有这个,你可以不小心声明一个新的变量,只是拼错另一个变量名。这是其中的一个事情,导致很多的悲伤,因为你试图调试VB程序,找出为什么你的程序不能正常工作。在我看来,这不应该是一个选项 – 它应该永远在。

选项严格“将隐式数据类型转换限制为仅扩大转换”。请参见here.启用此选项后,您不能意外地将一种数据类型转换为不太精确的另一种数据类型(例如,从整数到字节)。同样,默认情况下应打开的选项。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读