谁能告诉我为什么这会在运行时出错:
Dim mightBeNothing As List(Of String) = Nothing
Dim a As List(Of String) = IIf(mightBeNothing Is Nothing, New List(Of String)(), New List(Of String)(mightBeNothing))
我要ArgumentNullException
上二线了。如果我将最后一部分替换为:
Dim a As List(Of String) = IIf(mightBeNothing Is Nothing, New List(Of String)(), New List(Of String)())
它可以工作 - 但是如果什么都没有,New List(Of String)(mightBeNothing)
则永远不会调用构造函数mightBeNothing
,那么问题是什么?