C# 反射 List和字典Dictionary

Type type = typeof(Class.PlacemarkRender);
FieldInfo fieldInfo = type.GetField("_placemarkDic", BindingFlags.Instance | BindingFlags.NonPublic);

Dictionary<string, List<string>> dict = fieldInfo.GetValue(_placemarkRenderN) as Dictionary<string, List<string>>;

object variableValue = fieldInfo.GetValue(_placemarkRenderN);

IEnumerable<object> list = variableValue as IEnumerable<object>;

if (list != null)
{
foreach (var item in list)
{
if (value.Equals(item.GetType().GetProperty(PropertyName).GetValue(item, null).ToString()))
{
result = item.GetType().GetProperty(CheckPropertyName).GetValue(item, null).ToString();
}
}
}

posted @ 2022-01-20 20:37  左正  阅读(267)  评论(0编辑  收藏  举报