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

.net – Option Strict和Option Explicit有什么作用?,第1张

概述我看到这个帖子: 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 我看到这个帖子:

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

总结

以上是内存溢出为你收集整理的.net – Option Strict和Option Explicit有什么作用?全部内容,希望文章能够帮你解决.net – Option Strict和Option Explicit有什么作用?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1287296.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存