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?
Prevent a class from being inherited
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


VulpesRank #55 · 29.2K reputationPosted Feb 2, 2012, 6:50 AM EST
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.
Satyapriya NayakRank #47 · 31.5K reputationPosted Feb 2, 2012, 6:55 AM EST
Prabhu RajaRank #861 · 2.6K reputationPosted Feb 2, 2012, 8:03 AM EST
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