Why do we need interfaces?
Answers were Sorted based on User's Feedback
Answer / shivacharan
Reason1: In C# Multiple inheritence concept will be
implemented by Interfaces.
Reason2: When multiple ppl are working on one sigle
project, if they need to use some common functionality (for
example initializing the variables for thier modules)
instead of writing their own function name (like init,
initialize, setup etc etc) if we can write one single
function name (lets say initialize) then this function can
be implemented by any user who derives. That's it.
public interface IInitialize
{
void InitializeVar();
}
public classs Box:IInitialize
{
void InitializeVar()
{
//initializion of variables goes here
}
public classs Rectangle:IInitialize
{
void InitializeVar()
{
//initializion of variables goes here
}
this wil avoid all the confusion
Is This Answer Correct ? | 23 Yes | 1 No |
Answer / raman
when we wont to add new extended features we can go for
the interfaces.once you decalare the interface we need to
get those extented features we need to implent those
methods
Is This Answer Correct ? | 11 Yes | 1 No |
Is c# int immutable?
How do I create a single-file assembly?
What is the difference between decimal and integer?
What is the difference between select and selectmany?
Why we can't create the object of abstract class ?
15 Answers Assyst, CTS, HCL, IBM, L&T,
How does the clr work?
How long does it take to learn c# for unity?
What is the difference between inheritance and abstract class?
What is a template class?
How can you force derived classes to provide new method implementations for virtual methods?
Is a valid int value?
What is token in c#?