1
我有3個類(所有派生從相同的基類),我必須動態填充列表框與屬性名稱。通過屬性動態添加項目到列表框
我已經試過這樣
class Test : TestBase {
[NameAttribute("Name of the Person")]
public string PersonName { get; set; }
private DateTime Birthday { get; set; }
[NameAttribute("Birthday of the Person")]
public string PersonBDay {
get {
return this.bDay.ToShortDateString();
}
}
}
...
[AttributeUsage(AttributeTargets.Property)]
public class NameAttribute : Attribute {
public string Name { get; private set; }
public NameAttribute(string name) {
this.Name = name;
}
}
是否有可能在我的對象,尋找具有屬性NameAttribute
並獲得字符串形式的NameAttribute
的Name
屬性的所有屬性?
你救了我的命:)謝謝! – kyjan 2011-12-22 08:58:34