Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,

I am really confused about the purpose of interface.
Please consider the example:
i am creating an "IItem" interface and alloting two properties
"ItemName" and "ItemCode". any class that implements the "IItem" interface will the inherit these properties.
So my question is i can write these properties in the class without inheriting the "IItem" interface. so, why do i need them ?

thank you.
Posted

Yeah, some beginner people still have doubt with interface. Go through this cute link it will help you.

What's the Deal with Interfaces?[^]
 
Share this answer
 
v2
Comments
Anoop Ananthan 23-Oct-10 8:54am    
it was very good, thank you
Just expand the same scenario, If you want the same properties inside every class that inherited from Interface.

Interface force(Must) to implement the functionality.

for example. You are creating 100's of classes but the common functionality in every class you want is .ToString() method.

You are not going to develop all the classes, So this is an Technical non-voice Announcement for all the developer by inheriting from interface is to Must implement .ToString() Method.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
Look First .
In Interface all the function shud be abstract.

And the defination of the that function is defined in other class.
Let me know how much u did and what do u want.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900