微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我看到这个帖子:

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.启用此选项后,您不能意外地将一种数据类型转换为不太精确的另一种数据类型(例如,从整数到字节)。同样,认情况下应打开的选项。

原文地址:https://www.jb51.cc/vb/256331.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐