+ 2
Interface class ,purpose and why we use in c#?
Kindly in simple and wording.....
5 Answers
+ 3
I think, for a while some concepts are puzzling and one might ask what they are for đ
For now, I think the important part about interfaces to remember is:
- they define types
- classes can implement many interfaces but extend only one class
+ 3
Do you mean, what are interfaces for?
Well, I would say that they define a type, but not its implementation đ€đ
They abound. They let you separate parts of your program. That makes it easier to maintain and to modify. To switch. To test.
It may not become obviously immediately - give it time. If you stick with it and begin to read more advanced topics, you will begin to understand đ
+ 3
The latter fact plays a role in interface segregation principle. That basically means to strip down an interface to the central things it needs to provide. Implement ten very specialized interfaces that you know you need rather than one interface that forces a class to implement methods it doesn't need.
So, you see, their purpose is not so much for the functioning of the code. But rather the design and the designs properties for the software. But these are topics not covered here. But you will eventually come across them, read about them, learn about them đ
+ 2
Exactly,,,,,,Interface is confusing topic in C#......
+ 1
interfaces are related to:
* interface segregation principle --> SOLID
* design by contract
* separation of concerns
You must understand the concept of interface first!