[MyAttribute("x")]
public string Z{get;set;}
[MyAttribute("x")]
public void Y()
{
}
它找到方法上的attr就好了,但属性上的属性没有被识别。找不到属性的属性
public static bool HasAttribute(this MethodInfo m, Type attrType)
{
return Attribute.IsDefined(m, attrType);
}
我调试期间,在它正确地列出在CustomAttributes属性的方法看了看对象,但对房地产的一个是空的......任何人都可以解释一下吗?
似乎很奇怪。试图关闭你的编辑器并重新打开它?重新启动? – Jordan 2013-03-20 18:29:55
如何定义MyAttribute? – antonijn 2013-03-20 18:31:30
添加MyAttribute的声明?或者至少是AttributeUsage部分。 – JerKimball 2013-03-20 18:31:39