sealed keyword
what is difference between sealed class and private class because both are not inherited.
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.
VulpesPosted Jul 17, 2012, 5:10 AM
SenthilkumarPosted Jul 17, 2012, 2:31 AM
when you define the class as private then it will not allow you to inherit. But when you define the class as sealed then it allows you to create the instance for that class but it restrict to inherit further in any class.
Sealed class can't be base class to any other class. when you define the private class also same. But sealed allows you to create the object.
Jignesh TrivediPosted Jul 16, 2012, 8:06 AM
Please refer
http://forums.asp.net/t/1564250.aspx/1
http://www.dotnetfunda.com/forums/thread5643-main-advantage-of-private-class-and-sealed-classes.aspx
hope this will help you.
VulpesPosted Jul 16, 2012, 6:23 AM
It can be inherited from but only by other nested classes within the class in which the private class itself is nested (private classes can never be 'top level').
For example, this program compiles and runs fine, printing "Hello" twice to the Console:
In contrast a sealed class cannot be inherited from at all and can be either top level or nested.