【发布时间】:2011-05-25 18:05:09
【问题描述】:
给定这个接口
public interface IMyInterface
{
string Method1();
}
为什么这是有效的
public sealed class InheretedFromInterfaceSealed: IMyInterface
{
public string Method1()
{
return null;
}
}
但这不是
public class InheretedFromInterfaceWithSomeSealed: IMyInterface
{
public sealed string Method1()
{
return null;
}
}
然而对于抽象类来说这是一个有效的场景
public abstract class AbstractClass
{
public abstract string Method1();
}
public class InheretedFromAbstractWithSomeSealed: AbstractClass
{
public sealed override string Method1()
{
return null;
}
}
【问题讨论】:
标签: .net inheritance interface virtual sealed