How to prevent your class from being inherited? - C#.NET

How to prevent your class from being inherited?

You can use keyword 'sealed' in the class definition to prevent class from being inherited.

How to allow class to be inherited, but prevent the method from being over-ridden?

You can do so by declaring the class public and making the method sealed.
When do we declare a class as abstract in C#.NET?
C#.NET - When do we declare a class as abstract in C#.NET? - When at least one of the methods in the class is abstract...
How can you overload a method? - C#.NET
C#.NET - How can you overload a method? - Different parameter data types, different number of parameters, different order of parameters...
C#.NET Difference between System.String and System.StringBuilder classes
C#.NET - System.String and System.StringBuilder classes...
Post your comment