日期:2014-05-18 浏览次数:20911 次
class Program { static void Main(string[] args) { Console.WriteLine(Res.A); } } public class Test { [Load("ConsoleApplication1.Res.A")] public string A { get; set; } [Load("ConsoleApplication1.Res.B")] public string B { get; set; } } public class Load:Attribute { public Load(string name) { } }
public class Test { public Test() { //在构造函数中读取特性,反射对属性赋值 } [Load("ConsoleApplication1.Res.A")] public string A { get; set; } [Load("ConsoleApplication1.Res.B")] public string B { get; set; } } public class Load:Attribute { public Load(string name) { //反射对Value赋值 } public object Value { get; } }