标签:style blog color div sp log on c line
1,
public class Model { [Test(Name="zhu")] public string Id { get; set; } }
2,
public class TestAttribute : Attribute { public string Name; public static string GetAttrClass(Model m,string name) { Type type = m.GetType(); PropertyInfo f = type.GetProperty(name); if (f == null) { return null; } TestAttribute t = Attribute.GetCustomAttribute(f, typeof (TestAttribute)) as TestAttribute; return t.Name; } }
3,
Model m = new Model(); Console.WriteLine(TestAttribute.GetAttrClass(m,"Id"));
标签:style blog color div sp log on c line
原文地址:http://www.cnblogs.com/zhushangwei/p/3966928.html