+ 1
Really why we use interfaces ?? I can define methods freely without any inheritance.
please explain a necessary example, i am an unity3d programmer, i don't know what is interface advantage when i just can define methods separately on different components, it improves performance or something other in other code application like VS?
6 ответов
+ 5
well i use java not c# but in java for example when you make an array of an class you can only put instances of that class and sub-classes into the array. with interfaces you can sort-of do multiple inheritance😅
+ 4
probably for polymorphism...
+ 4
Without inheritance and interfaces there would be unnecessary duplication of code.
+ 1
its important to polymorphism ? i use unity game engine c#.
0
In Object-Oriented Programming, an Interface is a description of all functions that an object must have in order to be an "X". Again, as an example, anything that "ACTS LIKE" a light, should have a turn_on() method and a turn_off() method.
0
KiynL OOP is all about making things easy. I use the interface as it makes it clear that every class will have a similar and unique implementation for similar behavior.
Also Read about upcasting and downcasting :)