Hi Guys,
As example, string is a sealed class.
Come On! Get ready for innovation.
Thanks.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
mursaleen fayyazPosted Jun 2, 2013, 12:03 PM
Suppose, string is not a sealed class in .NET. What you will do with it?
Sandeep Singh ShekhawatPosted Jun 2, 2013, 11:56 AM
The sealed keyword enables you to prevent the inheritance of a class or certain class members that were previously marked virtual.
Classes can be declared as sealed. This is accomplished by putting the keyword sealed before the keyword class in the class definition. For example:
public sealed class D
{
// Class members here.
}
A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class. Sealed classes are primarily used to prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.
A class member, method, field, property, or event, on a derived class that is overriding a virtual member of the base class can declare that member as sealed. This negates the virtual aspect of the member for any further derived class. This is accomplished by putting the sealed keyword before the override keyword in the class member declaration. For example:
{}