+ 2

Interface class ,purpose and why we use in c#?

Kindly in simple and wording.....

28th Dec 2021, 7:03 PM
Danish Mehmood
Danish Mehmood - avatar
5 Réponses
+ 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
28th Dec 2021, 7:23 PM
Agnes Ahlberg
Agnes Ahlberg - avatar
+ 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 🙂
28th Dec 2021, 7:14 PM
Agnes Ahlberg
Agnes Ahlberg - avatar
+ 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 🍀
28th Dec 2021, 7:28 PM
Agnes Ahlberg
Agnes Ahlberg - avatar
+ 2
Exactly,,,,,,Interface is confusing topic in C#......
28th Dec 2021, 7:16 PM
Danish Mehmood
Danish Mehmood - avatar
+ 1
interfaces are related to: * interface segregation principle --> SOLID * design by contract * separation of concerns You must understand the concept of interface first!
29th Dec 2021, 7:35 AM
Kiwwi#
Kiwwi# - avatar