Link to home
Create AccountLog in
Avatar of stsanz
stsanz

asked on

Explain Interfaces

I am currently learning C#. I know C++ quite well, and a few of Java.
I thought a C# 'interface' was similar to an 'abstract' class when I suddenly discovered that there exists two independant keywords to declare classes : 'interface' and 'abstract'.
I don't really understand the notion of 'contract' in the definition of an interface.

Please explain C# interfaces, in what situation they should be used, and how they differ from abstract classes.
ASKER CERTIFIED SOLUTION
Avatar of Wim_Bl
Wim_Bl
Flag of Belgium image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of Razzie_
Razzie_

Also note that you can only do multiple inheritance from interfaces, not abstract classes.

Last, I advice you to look at this URL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconAbstractClassesVersusInterfaces.asp
Avatar of stsanz

ASKER

Thanks!