Re: Why I need Interface
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Sun, 10 Aug 2008 17:23:55 -0700
On Sun, 10 Aug 2008 14:33:01 -0700, Umeshnath <Umeshnath@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
My query is why I need an Interface, since my abstract class does the same
functionality
[...]
I know using interface we can go multiple inheritance
I am looking in such way the in terms of OOPS in C# what is the significance
If you understand that in C# you can only inherit one base class, I don't understand why you're asking the question.
An abstract class is useful for providing some default or fundamental implementation. But it ties you to a specific base class, preventing you from inheriting any other base class. If you have no implementation you want to provide through inheritance, why lock yourself into it by using an abstract class rather than an interface?
Another important reason to use an interface is that value types can't inherit abstract classes (and you can't make an abstract value type). So if you want for your interface to be able to be implemented by a value type, it has to be an interface, not an abstract class.
Basically, interfaces are more flexible, giving you more options. If you have no need for the extras that an abstract class provides, then an interface is the way to go.
Pete
.
- References:
- Why I need Interface
- From: Umeshnath
- Why I need Interface
- Prev by Date: Re: Retrying WebRequest.GetResponse()
- Next by Date: Imagelist versus Resources?
- Previous by thread: Why I need Interface
- Next by thread: Imagelist versus Resources?
- Index(es):
Relevant Pages
|
Loading