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

What is the use of tuple in c#?

0 Answers  


What are methods in C#?

0 Answers   Winsol Solutions,


why c# is pronounced as C-sharp instead of pronouncing it as C-hash? is there any technical reason behind it?

3 Answers  


How many constructors can a class have in c#?

0 Answers  


What is difference between ienumerable and enumerable in c#?

0 Answers  






What is boxing in c#?

0 Answers  


Where do we use static class in c#?

0 Answers  


what is the diference between casting and converting?

2 Answers  


What is a Command Object in C#?

0 Answers   B-Ways TecnoSoft,


Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

2 Answers   Siebel Systems,


What is the difference between null and string empty in c#?

0 Answers  


How do you serialize an object?

0 Answers  


Categories