VB.NET Nested With statements from different scopes

后端 未结 2 1913
天涯浪人
天涯浪人 2021-01-22 09:44

I am wondering if this is possible. I have a List Table (lstTable) that is on the same form that I am trying to fill in with information from a public structure (ELEM_DATA). I

2条回答
  •  遥遥无期
    2021-01-22 10:36

    'EXAMPLE:
    
    With New Object() {1, 2} 'With block 1
         Dim debug_1 As Object = .ToArray(0) 'Value 1 from object of block 1
             With New Object() {3, 4}  'With block 2
                     Dim debug_2 As Object = .ToArray(0)  'Value 3 from block 2
                     'How get 2 from block 1 of Object() {1, 2}?
                     '>>>
             End With
    End With
    'SOLUTION
    With New Object() {1, 2}    
         With New Object() {3, 4}.Concat(.ToArray)
              Dim debug_3 As Object = .ToArray(3)  'got value 2 from outer WITH block 1 [Object() {1, 2}]
              '---//---//---
         End With
         '---//---//---
    End With
    

提交回复
热议问题