Click here to Skip to main content
15,846,826 members
Please Sign up or sign in to vote.
1.20/5 (5 votes)
See more:
Please let me know why do we need interface with simple
i really didn"t get when to use does it makes difference..

Interfaces in C# (For Beginners)[^]article from CP might help you.
Share this answer
siva455 11-Mar-11 1:05am    
thanks for your answer but the article specifies how to use interface but not when to use and how does it makes difference...
See this discussion: When we use abstract and when we use interface...?[^].

Interesting article on the how interfaces a valuable: Using C# Interfaces to Make Applications Resilient to Changes[^].

Share this answer
Because C# is an Object Oriented Programming language. Interface is an important OOP entity, see, for instance: "Interfaces in Object Oriented Programming Languages"[^].
Share this answer
You shouldn't ask why do we need interfaces
but when do we need interfaces.

You can code without interfaces, but if you whant to make some behaviour generic you can use interfaces to code better.

i think you should also read about the differences between interfaces and abstract classes
Share this answer
Multiple inheritance is not supported in C#. but it can be achieved using interfaces...
Share this answer
CHill60 2-Jul-14 9:41am    
Hm ... not sure I would accept that statement without details of how it could be achieved. However, the post is over 3 years old and already adequately answered. This adds nothing to the answers already posted.
You can implement multiple interfaces, but only inherit from one abstract class.

An interface is an empty shell, there are only the signatures (name / params / return type) of the methods. The methods do not contain anything. The interface can't do anything. It's just a pattern

Abstract classes, unlike interfaces, are classes. There are more expensive to use because there is a lookup to do when you inherit from them.

Abstract classes look a lot like interfaces, but they have something more : you can define a behavior for them.
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