Hi Josema,
Let's understand the concept behind interfaces with an example. :)
We know of several birds that can fly...like sparrows, doves, crows etc. We
also know of several other entities that can fly...like kites, planes,
shuttles, rockets etc. But the way a sparrow flies is completely different
from the way a plane does. The way a plane flies is also completely different
from the way a shuttle does...We are sure of one thing but...all these
entities can FLY.
In terms of programming, we would define an interface IFlyingObjects with
the method Fly. And then would create seperate classes for each of the
examples above, each of which would implement the interface IFlyingObjects.
This would ensure that each of the object would have defined a method Fly
with their own specific implementation.
Interfaces are something the qualifies an entity. For example, calling a
person an actor would automatically mean that he/she is capable of *Acting*.
Calling another person a painter would mean he/she is capable of *Painting*.
But these people are all *People* as well - only the different qualities vary.
As per the programmatic definition, Interfaces define a contract - which
means that if a class implements an interface, we can be sure that it defines
all the members declared in the interface.
HTH,
- Rakesh
"Josema" wrote:
Hi,
Im new in this of the .net, and more or less i get the concepts of classes
events, delegates, but still i dont understand in wich kind of programs the
interfaces are very useful...
I would like to have a clear vision about the use of this and in wich cases
are better the use.
Could you put some examples (no neccesary code, only examples as ideas)
about when the use of interface its the best way to follow?
Any help would be grateful...
Thanks.