Re: why use the 'sealed' ?
- From: "Yunus Emre ALPÖZEN [MCAD.NET]" <yemre@xxxxxxxxxxxxxx>
- Date: Sun, 8 May 2005 11:53:16 +0300
Suppose that you have something like this;
public abstract class anAbstractClass
{
public abstract void someMethod();
public abstract void anotherMethod();
}
public class FirstDerivativeClass : anAbstractClass
{
public sealed override void someMethod()
{
}
public override void anotherMethod()
{
}
}
public class SecondDerivativeClass : FirstDerivativeClass
{
public override void anotherMethod()
{
}
}
public sealed class ThirdDerivativeClass : SecondDerivativeClass
{
public override void anotherMethod()
{
}
}
Now you have an abstract class and two abstract methods. At
FirstDerivativeClass, you implement someMethod() and do not want to anybody
to override it. You define it as sealed method. At SecondDerivativeClass you
can not override someMethod() but can override anotherMethod. At
ThirdDerivativeClass you still can override anotherMethod. But you guarantee
that there can not be a fourth derivative class by defining that class as a
sealed. Is it clear?
--
Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET
"Kylin" <gaotianpu@xxxxxxxxx> wrote in message
news:ObC0Ht5UFHA.3544@xxxxxxxxxxxxxxxxxxxxxxx
> any better reason ?
>
> --
> FireCrow Studio
> Kylin Garden
> EMail:gaotianpu@xxxxxxxxx
> ICQ:156134382
>
>
.
- References:
- why use the 'sealed' ?
- From: Kylin
- why use the 'sealed' ?
- Prev by Date: Re: Server.MapPath("~")
- Next by Date: Re: Cookies not sending in HttpWebRequest
- Previous by thread: Re: why use the 'sealed' ?
- Next by thread: Re: why use the 'sealed' ?
- Index(es):
Relevant Pages
|