2012-05-26 2 views
0

저는 작은 프로젝트를 진행 중이며 OOP 유지를 위해 몇 가지 문제가 있습니다.클래스의 속성을 컬렉션으로 가져옵니다.

Public Stations As New Microsoft.VisualBasic.Collection() 

그리고이 수업을 통해 : Station & Unit :

Collection Stations -> Object Station -> Collection Units -> Object Unit 

가있다 :

Public Class Station 

    Property name As String 
    Property stype As String 
    Property units As New Collection 
End Class 

Public Class unit 
    Property name As String 
    Property lbl As String 
    Property ip As String 
    Property utype As String 
End Class 

난 당신이 여기에 계층 구조를 볼 수 있습니다 생각

나는 전역 변수가 XML 파일에서 데이터를 가져 오는 코드 그것으로 rding 위의 컬렉션에 개체를 추가합니다.

그러나 Stations 컬렉션을 기반으로하는 단위 모음을 검색하는 방법을 알지 못했습니다. 나는이 같은 시도 :

Dim st = Stations.Item("The key of a specific object in the Stations collection") 
    Dim stUnits = st.GetType().GetProperty("units") 

을하지만 때 나는 컬렉션을 검색하기 위해 노력하고있어 :

For Each unit In stUnits 

그것은 콜렉션 아니라고 말한다합니다. 약간의 혼란 스러워요. 가능한 모든 도움을 주셔서 감사합니다.

답변

0

바보 나. 방송국 개체로 st을 설정 잊으.

Dim st As Station = Stations.Item("The key of a specific object in the Stations collection") 

그리고, 단순히 :

Dim stUnits = st.units 
관련 문제