question

YoonYoungHyun-4955 avatar image
0 Votes"
YoonYoungHyun-4955 asked DuaneArnold-0443 answered

What is the keyword sealed used for in a Class definition?

I need a help. Thank you.

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

DuaneArnold-0443 avatar image
0 Votes"
DuaneArnold-0443 answered

It's used to stop a derived class from inhibiting the sealed class' behavior/methods.

https://www.geeksforgeeks.org/c-sharp-sealed-class/#:~:text=Sealed%20classes%20are%20used%20to,derived%20from%20a%20sealed%20class.

https://www.c-sharpcorner.com/article/sealed-class-in-C-Sharp/#:~:text=The%20main%20purpose%20of%20a,Brushes%20classes%20of%20the%20System.

I have never had to make a sealed class ever starting with C# usage back in 2002 or so. :) I have seen base class with sealed methods that were overridable.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.