我有这段代码:
public class Tag : ValueObjectBase
{
public virtual string Name { get; set; }
public virtual bool IsDeleted { get; set; }
public virtual long Count { get; set; }
public virtual DateTime CreationTime { get; set; }
protected override void Validate()
{
}
我只是从Tag继承了NewsTag类:
public class NewsTag : Tag
{
public NewsTag(string name, int count)
{
Count = count;
Name = name;
}
protected override void Validate()
{
throw new NotImplementedException();
}
}
为什么Resharper建议我将NewsTag课程设为密封?
答案 0 :(得分:1)
我刚刚找到了答案!有关here和其他相关帖子的更多信息,请参阅Eric Lippert的博客文章: http://www.matthewedmondson.info/2012/08/virtual-method-call-in-contructor.html
还看看这个问题: Virtual member call in a constructor