Click here to Skip to main content
14,920,690 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hi any body help me . regarding..
is compulsory to implement all the methods in interface? that i implement to my class? sorry for my poor english
thank you

Is is compulsory to ask questions like this one?

Each and every help page in interfaces will have an answer to this question.
However, one delicate moment is: if your implementing type is class and if this class is derived from some class where this interface is already implemented, you can re-implement only some of the interface members.

The ability to do this is one great benefit over C++ where implementing COM interfaces is some problem due to lack of this feature.

Abhinav S 13-May-11 6:09am
5 - very useful. I did not know about this extra condition.
Thank you, Abhinav.
Wayne Gaylard 13-May-11 7:11am
That's useful to know. Thanks.
It is. Thank you, Wayne.
Yes. It is. You wont be able to compile your code without at least providing the method stub in your class.
Strictly speaking, this is true, my 5, but... there is one moment...
please see my answer.
Yes, it is mandatory to implement all the methods in a class that implements an interface unless and until that class is an Abstract class.

Let's Make it Simple,

You have two choices:

- implement every method required by the interface
- declare the missing methods abstract in your class. This forces you
to declare your class abstract and, as a result, forces you to
subclass the class (and implement the missing methods) before you
can create any objects.
Correct, my 5, but you can also re-implement it without virtual.

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