我要做的就是检查对象是否为空,但是不管我做什么,如果它编译了,它NullReferenceException
只会抛出一个试图检查的东西!这是我所做的:
If ((Not (comp.Container Is Nothing)) And (Not (comp.Container.Components Is Nothing))) Then
For i As Integer = 0 To comp.Container.Components.Count() - 1 Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
If ((Not IsDBNull(comp.Container)) And (Not IsDBNull(comp.Container.Components))) Then
For i As Integer = 0 To comp.Container.Components.Count() - 1 Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
If ((Not IsNothing(comp.Container)) And (Not IsNothing(comp.Container.Components))) Then
For i As Integer = 0 To comp.Container.Components.Count() - 1 Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
If ((Not (comp.Container Is DBNull.Value)) And (Not (comp.Container.Components Is DBNull.Value))) Then
For i As Integer = 0 To comp.Container.Components.Count() Step 1
fixUIIn(comp.Container.Components.Item(i), style)
Next
End If
我浏览了VB书籍,搜索了多个论坛,所有应该工作的内容都不起作用!很抱歉提出这样的补救性问题,但我只需要知道。
大家知道,调试器说null对象是 comp.Container