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
what is the syntax to inherit from a class in c#?
Explain the difference between // comments, /* */ comments and /// comments?
What is the difference between abstract and virtual?
What is serialization in c#?
Constructor to an arbitrary base constructor?
Why delegates are safe in c#?
Explain the various types of classes used in c#?
Can You Prevent Your Class From Being Inherited By Another Class?
What is a delegate? How can it works?
What is null propagation c#?
What is returned if you pass the value 12.34 to the parsefloat () function?
Can abstract class have parameterized constructor?
What is difference between string and string builder?
What is callback delegate in c#?
What are the new features in c# 2.0?