|
 |
aspx_beginners thread: About Interfaces ??
Message #1 by "Vajjrapani" <vr@l...> on Fri, 14 Mar 2003 17:14:15 +0530
|
|
What are interfaces and why is they important in VB or VB.NET ??
what are uses of writing custom interfaces ??
Why do we declare the method's and properties in interface and implement
it in the class using Implements keyword ?? instead we can directly define
the methods and properties in class itself ?? why do we need to declare it
in the interface ?? what is the significance of it ??
anyone can answer me in detail....??
thanks in advance...
rgds,
vajjar
Message #2 by "Dale Purdon" <dale@t...> on Fri, 14 Mar 2003 14:17:48 +0200
|
|
If your class implements a certain interface, it is like a 'contract' or
agreement stating that this class exposes these methods and must be used
like this.
You have an interface called 'Animal'.
In your project, you are creating a game which involves many different
kinds of animals. You will have a class for each animal that exists in
your games (eg. A dog,cat,mouse and horse class)
All of these animals have certain things in common, they can
run,eat,sleep etc.
However, all these animals perform their daily routines differently eg.
A dog eats more than a mouse,a dog runs faster than a cat (he he).
Now normally, you would create a class for each animal, and give them
the methods run, eat and sleep. And simply code the methods differently.
Now instead of duplicating the definition of all the methods through out
the animal classes, you can simply allow all the animal classes to
IMPLEMENT one interface. This interface will simply define the methods
run,eat and sleep.
You also already now know that because your classes implement this
interface, they WILL support these methods (you know that all your
animals run,eat and sleep).
Hope this makes more sense, believe me, it took me a while to get the
hunch of it all (its still becoming clearer to me as I use them).
Later....
-----Original Message-----
From: Vajjrapani [mailto:vr@l...]
Sent: 14 March 2003 01:44 PM
To: aspx_beginners
Cc: pro_vb@p...
Subject: [aspx_beginners] About Interfaces ??
What are interfaces and why is they important in VB or VB.NET ??
what are uses of writing custom interfaces ??
Why do we declare the method's and properties in interface and implement
it in the class using Implements keyword ?? instead we can directly
define
the methods and properties in class itself ?? why do we need to declare
it
in the interface ?? what is the significance of it ??
anyone can answer me in detail....??
thanks in advance...
rgds,
vajjar
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003
|
|
 |