Click here to Skip to main content
14,828,794 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please guide me about interface, when to use interface and why we use interface?


The first hit by Google is here[^] on CodeProject.
attiq_khan 4-Jul-11 5:25am
thanks alot
Reasonable, my 5. Please see my answer, too.
Google is your friend! Start here Abstract Class versus Interface[^]

attiq_khan 4-Jul-11 5:25am
thanks alot
Google can help - your subject line used as a search term will take you to MSDN[^] and the start of a series of short articles on when and why to use interfaces.

Please, try to use google first - it can save you a lot of time...
attiq_khan 4-Jul-11 5:24am
thanks alot
OriginalGriff 4-Jul-11 5:32am
You're welcome!
Reasonable, my 5.
Please see my answer, too.
You got some reasonable answers. Please also see the useful discussion here:
When we use abstract and when we use interface...?[^],
Difference between abstract class and interface if they have same no of methods and var[^].

Please check out not just my answers, but all other posts. Some are interesting and useful.

Richard MacCutchan 5-Jul-11 5:37am
A 5 for your answer which points the way to lots of good information. I must read the article in the link I posted to see if it really explains the issues, as I see so many repeats of this question.
Thank you, Richard.

use interface are
1. Apply Common Standard Coding
2. Casting

Casting means we have an object that contain all the function and variable in it but we want only one function in that obejct then we create an interface and cast the object. in the case of remoting we don't know the type of object so we cast that object using our interface
Interfaces are used when you want to establish some contract. That is the common use case for the interfaces.
OK, pretty much correct, but why not an abstract class then? Also a contract?

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