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
Does c# replace c++?
What is the difference between c and c# programming?
What are the Uses of CLR
What is public or shared assemblies ?
What does return do in for loop?
What is difference between override and new in c#?
how to sort an array in c#
What is cshtml?
How many destructors can a class have?
What are some of the commonly used commands in sqlcommand?
Why do we use classes?
What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?
List some of the basic string operation?
What is the purpose of the integer parse method the decimal parse method?
Differentiate between copy and default constructor.