Why do we need interfaces?

Answers were Sorted based on User's Feedback



Why do we need interfaces?..

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

Why do we need interfaces?..

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

Post New Answer

More C Sharp Interview Questions

Can we change static variable value in c#?

1 Answers  


What is difference between "as" and "is" keyword?

1 Answers  


How to find out that the code is written as managed or un-managed code?

1 Answers   Amazon,


Can we maintain state in webservice?

1 Answers  


How?s method overriding different from overloading?

3 Answers  


What does dbml mean in texting?

1 Answers  


Compare and contrast between the System.Array.CopyTo() and Clone()?

1 Answers   Siebel,


What is tryparse c#?

1 Answers  


Why interface is required?

1 Answers  


Is goto statement supported in C#? How about Java?

2 Answers  


How do you specify a custom attribute for the entire assembly (rather than for a class)?

1 Answers  


Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve ?

1 Answers  


Categories