【发布时间】:2015-02-02 21:25:50
【问题描述】:
我的问题是有什么方法可以使用反射来检索参数列表及其值?
我想使用反射从 PropertyInfo 中获取参数列表。
Author author = (Author)attribute;
string name = author.name;
不正常。因为会有很多Attribute,不是Author类型。
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = true)]
public class Author : Attribute
{
public Author(string name, int v)
{
this.name = name;
version = v;
}
public double version;
public string name;
}
public class TestClass
{
[Author("Bill Gates", 2)]
public TextBox TestPropertyTextBox { get; set; }
}
【问题讨论】:
标签: c# reflection