What is the benefit of using interfaces? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the benefit of using interfaces?

I recently finished the C# course, but the purpose of interfaces eludes me. I understand (and love) inheritance, but interface and abstract classes seem pointless. Interface (and abstract) basically seems like a template class. Looking at the demo code for the lesson, it seems like you could remove the interface (and the implementation) entirely and the code would still fully function, and be fewer lines of code. Do interfaces actually add anything? Or are they just a way to keep organized? With inheritance, you can bring in existing methods without rewriting them, but interfaces don't seem to bring anything to the table. The idea of a class implementing multiple interfaces seems pointless since you still have to write out the full code for each method you are pulling in from the parent. Thank you in advance.

12th Apr 2019, 6:10 PM
Jeremy Simmons
1 Answer
+ 2
Maybe this article helps you: https://dzone.com/articles/c-interfaces-what-are-they-and In Java it is more or less the same. I am not at the point that I really need interfaces. But I think in large projects they make sense.
12th Apr 2019, 8:03 PM
Denise Roßberg
Denise Roßberg - avatar