C# Sealed - c# - c# tutorial - c# net
What is sealed keyword in C# ?
- C# sealed keyword applies restrictions on the class and method.
- If you create a sealed class, it cannot be derived.
- If you create a sealed method, it cannot be overridden.
Sealed class csharp in c# Example
Note: Structs are implicitly sealed therefore they can't be inherited.
C# Sealed class
- C# sealed class cannot be derived by any class. Let's see an example of sealed class in C#.
C# examples - Output :
C# Sealed method
- The sealed method in C# cannot be overridden further. It must be used with override keyword in method.
- Let's see an example of sealed method in C#.
C# examples - Output :
Note: Local variables can't be sealed.