Type t = Type.GetType(obj.ToString());
PropertyInfo p = t.GetProperty("Test");
dynamic kk = p.GetValue(obj, null);
Run Code Online (Sandbox Code Playgroud)
在这里,Test是一个int List.我需要得到int列表中所有值的总和,即.,kk.
var list = p.GetValue(obj, null) as IEnumerable<int>;
var result = list.Sum();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2019 次 |
| 最近记录: |