sankar s

sankar s

  • NA
  • 9
  • 1.3k

Why We Need Interface?

Feb 14 2013 12:14 AM
I have a doubt on interface. My question is why exactly i need interface? i read few articles in the net but none of them explained me clearly.
1.) Every one just say interface is a contract that can be implemented in a class.
2.) They just give an example of Idisposable, IComparable etc.
3.) My question is when i implement interface called ICompareable i should and must use CompareTo()  method i agree, my question is that in CompareTo() method i will be writing the logic. So wy do i need to implement Icomparable interafce? I can write the method directly in a base class and i can use that method in derived calss?

Answers (4)