like mentioned above, interfaces are mostly used because there is nothing like multiple inheritance in C#. It is more a decision between using an interface or an abstract class. I prefer to use interfaces when decoupling a system through specific patterns,
so it's more about a better design.
Regards.
If my post solves your problem, please mark as answer.
through interfaces we can have multiple inheritance feature in c#
If i have a website which have same methods and functionalities in whole site ... we can put the name of those methods like ,add,update and delete... by inheriting interface we can use those methods.
Please click "Mark as Answer" if this helped you.
My Blog: http://shivaniaspnet.blogspot.in
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Marked as answer by Amy Peng - MSFT on Jan 15, 2013 01:20 AM
When working with larget project with team work then it is required to work with one common pattern so project lead or any senior developer desing interface and all other need to follow that interface so all implementaion will be one common pattern so any
one what to use this code or component then easily understand the structure...
If you have still any question then let me know I will provide more details
My Tech Blogs MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
Interfaces in C# are provided as a replacement of multiple inheritance
Shivarajb
to achieve multiple inheritance we use interface.
imho, it's more correct to say that interfaces in C# are provided as an alternative to
multiple inheritance.
multiple inheritance involves a single class being derived from more than one
base class ... an interface is not a
class.
Amy Peng - MSFT
the problem of name ambiguity that is found in C++.
Amy, the same problem exists in c# ... solutions to avoiding this problem include appropriate choice of names and appropriate qualification of names.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
spriyanair
Member
19 Points
61 Posts
why we used Interface in C#
Jan 07, 2013 06:06 AM|LINK
for interface also we have to create a class to implement the methods.we can create obj and call use the same class then why we need interface
Shivarajb
Member
75 Points
43 Posts
Re: why we used Interface in C#
Jan 07, 2013 06:10 AM|LINK
C# does not support for multiple inheritance,to achive multiple inheritance we use interface.
.
BestRegards.
Shivaraj B
Prathap Kuma...
Member
615 Points
163 Posts
Re: why we used Interface in C#
Jan 07, 2013 09:46 AM|LINK
Hi,
I hope this links help's u
http://www.codeproject.com/Questions/392978/what-is-Interface-in-Csharp-and-why-we-are-using-i
http://stackoverflow.com/questions/2026054/why-do-we-use-interface-is-it-only-for-standardization
Prathap
Horizon_Net
Star
8277 Points
1435 Posts
Re: why we used Interface in C#
Jan 07, 2013 04:21 PM|LINK
Hi,
like mentioned above, interfaces are mostly used because there is nothing like multiple inheritance in C#. It is more a decision between using an interface or an abstract class. I prefer to use interfaces when decoupling a system through specific patterns, so it's more about a better design.
If my post solves your problem, please mark as answer.
shivani.gupt...
Participant
873 Points
315 Posts
Re: why we used Interface in C#
Jan 08, 2013 11:35 AM|LINK
For various reason we use interface
My Blog: http://shivaniaspnet.blogspot.in
Amy Peng - M...
Star
10123 Points
958 Posts
Microsoft
Re: why we used Interface in C#
Jan 08, 2013 11:41 AM|LINK
Hi,
Because C# does not support multiple inheritance, Interface is provided as an alternative to multiple inheritance in the C#.
Purposes of Interfaces:
1. create loosely coupled software
2. support design by contract (an implementor must provide the entire interface)
3. allow for pluggable software -allow different objects to interact easily
4. hide implementation details of classes from each other
5. facilitate reuse of software.
The following article can help you to understand: http://dotnet.dzone.com/articles/c-interfaces-what-are-they-and .
Best Regards,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store
gerrylowry
All-Star
20513 Points
5712 Posts
Re: why we used Interface in C#
Jan 08, 2013 11:42 AM|LINK
@ spriyanair
in many cases, you may not want to use an interface:
please read my reply http://forums.asp.net/post/5219333.aspx to this forums.asp.ned thread Difference between interface and abstract class.
g.
amitpatel.it
Star
7946 Points
1865 Posts
Re: why we used Interface in C#
Jan 08, 2013 11:49 AM|LINK
When working with larget project with team work then it is required to work with one common pattern so project lead or any senior developer desing interface and all other need to follow that interface so all implementaion will be one common pattern so any one what to use this code or component then easily understand the structure...
If you have still any question then let me know I will provide more details
MCPD Enterprise and Web Application
MCTS Web, Window and Enterprise Application
gerrylowry
All-Star
20513 Points
5712 Posts
Re: why we used Interface in C#
Jan 08, 2013 12:15 PM|LINK
@ Amy Peng - MSFT, Shivarajb
imho, it's more correct to say that interfaces in C# are provided as an alternative to multiple inheritance.
multiple inheritance involves a single class being derived from more than one base class ... an interface is not a class.
Amy, the same problem exists in c# ... solutions to avoiding this problem include appropriate choice of names and appropriate qualification of names.
g.
Amy Peng - M...
Star
10123 Points
958 Posts
Microsoft
Re: why we used Interface in C#
Jan 09, 2013 01:53 AM|LINK
Hi gerrylowry,
Yes, you are right.
What you said is correct.
Thank you very much for telling me.
Thanks again.
Best Regards,
Amy Peng
Feedback to us
Develop and promote your apps in Windows Store