考慮這段代碼:在企業庫中,抽象Validator.cs如何具有方法定義?
public abstract class Validator
{
protected Validator()
{
}
protected abstract void ValidateCore(object instance, string value, IList<ValidationResult> results);
public void Validate(object instance, string value, IList<ValidationResult> results)
{
if (null == instance) throw new ArgumentNullException("instance");
if (null == results) throw new ArgumentNullException("results");
ValidateCore(instance, value, results);
}
}
看那Validate()
過載,抽象類怎麼能有這樣的定義是什麼?
是的 - 抽象方法不是接口。 – 2010-04-24 06:14:09
事實上,一個抽象類可以沒有抽象方法(你可以測試它),儘管這不是定義抽象類的常用方法。 – 2010-04-25 11:09:57
嗯...有趣,謝謝! – Soham 2010-04-25 17:14:24