密封类和类成员
//密封类不能用作基类,禁止派生 public sealed class B { //Class members here. } //派生类重写方法、索引器、属性或事件时,可以将成员声明为密封成员,之后继承的类成员不能再覆写这些成员,只能用new关键字 public class C { public virtual void OutPut() { Console.WriteLine("I am Class C."); } } public class D:C { public sealed override void OutPut() { Console.WriteLine("I am Class D."); } } public class E : D { public new void OutPut() { Console.WriteLine("I am Class E."); } }