I m trying to understand Interfaces so that I can implement them in my programs but I m not able to imagine how should i use them.
Also give me some eg of using them with multiple inheritance in C#
I m trying to understand Interfaces so that I can implement them in my
Share
A good example for an interface is a repository pattern. Your interface will define methods like Get, GetAll, Update, Delete, etc. No implementation, just function signatures.
Then, you can write a ‘concrete’ implementation of that class to work with, say, MySQL. Your UI should only refer to the interface, though.
Later, if you decide to change to Microsoft SQL, you write another concrete implementation, but your UI code doesn’t have to change (much).
Multiple inheritance doesn’t exist in C#, in the sense that you can only inherit from one ‘concrete’ class; though you can inherit (or ‘implement’) as many interfaces as you want.