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

Name which controls do not have events?

0 Answers  


I have to create a windows application using C# .net to Modifiy the XML file. The application have to show the node and node value. plz help me.

3 Answers   Merrill Lynch,


Explain how obfuscator works in .net

0 Answers  


If a class is a ref type, how we can pass to a function.

1 Answers   Synechron,


Can we store different data types in arraylist in c#?

0 Answers  






What is the use of table aliases?

0 Answers  


What is delegation in oops?

0 Answers  


What is an extension method in c#?

0 Answers  


What is difference between array and list in c#?

0 Answers  


Is int reference type c#?

0 Answers  


What is c-sharp (c#)?

0 Answers  


What is the difference between const and readonly in c#.net?

0 Answers  


Categories