중첩 된 속성에서 값을 가져와야합니다.중첩 된 속성에서 값을 가져와야합니다.
MainClass에는 Student Class 유형이 있습니다.
MainClass obj = new MainClass();
obj.Name = "XII";
obj.Students = new List<Students>()
{
new Students() { ID = "a0", Name = "A" },
new Bridge() { ID = "a1", Name = "B" }
};
Type t = Type.GetType(obj.ToString());
PropertyInfo p = t.GetProperty("Students");
object gg = p.GetValue(obj, null);
var hh = gg.GetType();
string propertyType = string.Empty;
if (hh.IsGenericType)
{
string[] propertyTypes = hh.ToString().Split('[');
Type gggg = Type.GetType(propertyTypes[1].Remove(propertyTypes[1].Length - 1));
foreach (PropertyInfo pro in gggg.GetProperties())
{
if (pro.Name.Equals("Name"))
{
// Get the value here
}
}
}
목록의 '찾기'메소드를 사용하지 않는 이유는 무엇입니까? – V4Vendetta
정확히 무엇을 찾으려고합니까? 그리고 정말로 반사가 필요합니까? 'Bridge' 클래스는 무엇을위한 것인가? – SWeko