我有一個奇怪的問題。當我在使用數組時,IIf正在搞亂。顯然它是檢查我的其他語句,即使它沒有被激活。下面是一些演示問題代碼:vb.net - IIf拋出奇怪的異常
'works
Dim test As String = "bleh"
If values.Length < 6 Then
test = "200"
Else
test = values(5)
End If
'throws indexoutofrange exception
Dim itemLimit As String = IIf(values.Length < 6, "200", values(5))
您正在使用什麼版本的VisualStudio? – Pondidum 2011-03-30 23:15:12
我正在使用Microsoft Visual Basic 2010 Express。 – Phil 2011-03-30 23:16:25
[使用VB.NET IIF的可能的重複我得到NullReferenceException](http://stackoverflow.com/questions/428959/using-vb-net-iif-i-get-nullreferenceexception) – MarkJ 2012-02-21 08:50:09