Preventing a C# subclass from overwriting a method

后端 未结 4 1340
清歌不尽
清歌不尽 2021-01-18 09:05

Say I have an abstract parent class called \"Parent\" that implements a method called \"DisplayTitle\". I want this method to be the same for each subclass that inherits \"

4条回答
  •  终归单人心
    2021-01-18 09:46

    Use the sealed modifier to prevent subclasses from overriding your classes, properties, or methods. What isn't working when you use sealed?

    http://msdn.microsoft.com/en-us/library/88c54tsw.aspx

提交回复
热议问题