Hi friends,
I want to know that If we have a class and can we prevent our class from being inherited and becoming a base class for some other classes?
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.
Prabhu RajaPosted Feb 2, 2012, 1:03 PM
We can Prevent a Class from Being inherited by using Sealed Keyword.
@Satyapriya is Correct, that Sealed Classes can not be a Base Class.
Added to that, Also Its obvious that Sealed Class can not be an abstract class.
Thank You
Satyapriya NayakPosted Feb 2, 2012, 11:55 AM
VulpesPosted Feb 2, 2012, 11:50 AM
public sealed class MyClass
{
// code
}
Notice also that a 'static class' is implicitly sealed, though it's an error to add the sealed modifier to it.