在C#中的类的实例方法中使用GetValue方法

时间:2017-05-11 11:19:26

标签: c# .net reflection

我有方法# views.py def page(request, page_name): # use the page_name argument as you like 的简单类,我想枚举该对象的所有私有和实例属性(引用)。为什么我不能接受这个价值。我看到我需要将对象传递给ToHtmlString()方法,以便运行时知道哪个参考反射的值会得到,但看起来我不能那样做?如何在枚举此实例的所有属性时使用GetValue

GetValue

1 个答案:

答案 0 :(得分:1)

看起来你错过了一个结束“)”和一个.ToString()

html.AppendLine(new GenericItemView((property.GetCustomAttribute(typeof(DescriptionAttribute))as DescriptionAttribute)?. Description,property.GetValue(source).ToString())。ToString());

相关问题