【发布时间】:2012-12-07 17:52:08
【问题描述】:
如何访问属性类中的属性值。我正在编写一个自定义验证属性,该属性需要根据正则表达式检查属性的值。这 例如:
public class MyAttribute
{
public MyAttribute (){}
//now this is where i want to use the value of the property using the attribute. The attribute can be use in different classed
public string DoSomething()
{
//do something with the property value
}
}
Public class MyClass
{
[MyAttribute]
public string Name {get; set;}
}
【问题讨论】:
标签: asp.net-mvc-3 c#-4.0 custom-attributes