【发布时间】:2010-11-05 07:12:08
【问题描述】:
这是一个关于 VB.NET 语言的问题。由于我每天都在使用它,所以我只是试图了解它的一些构造背后的动机。
我才发现这一行:
If myObject Is Nothing then
和这个一样正确:
If Nothing Is myObject Then
同样的结果。使用 ildasm,我们可以看到这些行被翻译成:
if myObject = null then
和
if null = myObject then
嗯,但是,在 VB.NET 中,你不能写:
if myObject = Nothing Then
编译器不会接受。
嗯,对我来说,If Nothing Is myObject 远不如 If myObject = Nothing .
为什么 VB.NET 作者的想法正好相反?有什么提示吗?
【问题讨论】:
-
这是为了确保 c 程序员会继续讨厌 VB。 :P
-
@Jon - 你不必是 C 程序员就可以讨厌 VB。只是说。
-
当然,用 C 编写喜剧代码要困难得多,例如:If You Is Nothing Then WontBeNothing()
-
“Is You Is or Is You Aint My.Baby”是否编译?
标签: .net vb.net compiler-construction