Answer Posted / kiran
We will go for an interface when we want to implement a
specific behaviour.
ex:
1.My class x implements IDisposable interface to handle
cleaup operation. I have to implement that behaviour by
implementing the method interface method Dispose()
explicitly in my code.
class x:IDisposable
{}
2.My class y implements IComparable interface to implement
sorting between a list of objects created of type y. Here I
have to implement CompareTo method.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Explain the difference between abstract class and interface.
What are concrete classes?
Are c# generics the same as c++ templates?
What will a loop recorder show?
How to achieve polymorphism in c#?
Why we use methods in c#?
Where is c# compiler located?
Can structs in c# have destructors?
What is difference between event and delegate in c#?
Why singleton pattern is used in c#?
What is difference between method and function in c#?
What is the purpose of static?
What are the advantages of interface in c#?
What does args mean in c#?
Why do we use partial class in c#?