Sei*_*bar 1 .net language-agnostic exception
在.NET中,如果有人将非法值传递set { }给属性的某个部分,应该抛出什么类型的异常?
例:
public string Provider
{
get { return _provider; }
set
{
if (String.IsNullOrEmpty(value)) throw new Exception("Provider cannot be null or empty."); //what type of exception should be thrown here instead?
_provider = value;
}
}
Run Code Online (Sandbox Code Playgroud)
注意:
我问这个问题,因为它适用于.NET,但它也适用于许多其他语言.因此,如果您有一个适用于.NET框架之外的其他问题的好答案,请发布!
| 归档时间: |
|
| 查看次数: |
228 次 |
| 最近记录: |