//密封類不能用作基類,禁止派生 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."); } }