내가하고 싶은 것은 객체가 null인지 확인하는 것입니다.하지만 컴파일 할 때 확인을 시도하는 것은 NullReferenceException
입니다. 여기에 내가 무슨 짓을했는지의 :null 체크 VB에서
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 책을보고 여러 포럼을 검색하고 작업을해야 모든 것을하지 않는 것! 그러한 구제 적 질문을하는 것에 대해 유감스럽게 생각합니다. 그러나 나는 단지 알 필요가 있습니다. 그냥 알다시피
는, 디버거는 널 객체가 AndAlso
의
표준 And
-comp.Container
이
당신이 대답을 기다리는 동안 일하는 것을 얻기 위해, 때로는 사물이 경우 중첩 된 Ifs의 한 쌍을 사용하여 같은 .. 일을 리팩토링 할 수있다. –