+ 3
What think do you can sayme about interface in C#? It's confuse for me respect abstracta
Interface
4 Respuestas
+ 3
A class can inherit from just one base class, but it can implement multiple interfaces.
Therefore, by using interfaces you can include behavior from multiple sources in a class.
+ 3
They provide a way to implement multiple behaviours without using multiple inheritance directly.
+ 2
I do find interfaces a really difficult topic.
Although I am very happy with the defined interfaces like IEnumerable, IDisposable, IComparable. They make live a lot easier.
In need to admit, I use there functionality the most in already defined types. But it is good to be aware of the fact that it is a interface that you are using.
A interface is a contract. A description of the name of the method, its returns value and the parameters.
0
Abstract class is a class with implementation and can not have an instance from it. every class can inherit from just one class
Interfaces have not any implementation and they made for multiple inheritance and fix multiple inheritance problem
You can have unlimited interface inherited
Why interface and not class:
Interface fix function of method and constructor problem if two class inherited from one same class
create loosely coupled software
support design by contract (an implementor must provide the entire interface)
allow for pluggable software
allow different objects to interact easily
hide implementation details of classes from each other
facilitate reuse of software