Hello Sir...........
Why are you used sealed class in c# and which condition we can apply sealed class?
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.
Jignesh TrivediPosted Jun 5, 2014, 2:23 AM
hi,
Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited.
public sealed class A
{
// Class members here.
}
public class B : A
{
}
above code is give compilation error.
refer
http://msdn.microsoft.com/en-IN/library/ms173150.aspx
hope this will help you.
Keyur PatelPosted Jun 6, 2014, 8:50 AM
It's good explanation about the sealed class in microsoft site.
http://msdn.microsoft.com/en-us/library/88c54tsw.aspx
Shweta LodhaPosted Jun 6, 2014, 3:08 AM
Anupam SinghPosted Jun 5, 2014, 3:43 AM
In short sealed class can not have any child or derived class.
In .NET
for example in .NET framework, String is a sealed class .
Lakshmanan Sethu SankaranarayanPosted Jun 5, 2014, 3:19 AM
Please check this
http://www.c-sharpcorner.com/UploadFile/mahesh/SealedClasses11142005063733AM/SealedClasses.aspx
Abhishek KumarPosted Jun 5, 2014, 3:17 AM
When applied to a class, the sealed modifier prevents other classes from inheriting from it. Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited.
Using sealed keyword will make class sealed and restricted as below.
sealed class SealedClass
{
}
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.
Sealed class should be mainly used for security purpose.
Hope this makes sense to you. Many Thanks.
Princy GuptaPosted Jun 5, 2014, 2:24 AM
good article:
http://www.codeproject.com/Articles/239939/Csharp-Tweaks-Why-to-use-the-sealed-keyword-on-cla