Kir*_*oev 0 .net c# silverlight
是否可以使用某种属性来抛出异常.这就是我的意思.而不是这样做:
public int Age
{
get
{
return this.age;
}
set
{
this.age = value;
NotifyPropertyChanged("Age");
if (value < 18)
{
throw new Exception("age < 18");
}
}
}
Run Code Online (Sandbox Code Playgroud)
做这样的事情:
[Range(18,100, ErrorMessage="Must be older than 18")]
public int Age
{
get
{
return this.age;
}
set
{
this.age = value;
NotifyPropertyChanged("Age");
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激!
最诚挚的问候,基里尔
归档时间: |
|
查看次数: |
894 次 |
最近记录: |