为什么第一个if语句的结果为true?我知道如果我使用“是”而不是“=”,那么它不会评估为真。如果我用“Foo”替换String.Empty,它不会计算为true。 String.Empty和“Foo”都具有相同类型的字符串,那么为什么一个评估为真,另一个不是?Nothing = String.Empty(为什么它们相等?)
//this evaluates to true
If Nothing = String.Empty Then
End If
//this evaluates to false
If Nothing = "Foo" Then
End If
您是否在使用'.Equals()'方法进行比较? – Amber 2010-04-13 21:14:44
我添加了一个代码片段。实际上我并不需要在null和空字符串之间进行比较,我只是很好奇为什么该语句的计算结果为true。 – 2010-04-13 21:25:44