Where would you use abstract class and interface in VB.NET?
Where would you use abstract class and interface in VB.NET? give also example!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Martin van EerdePosted Mar 14, 2011, 7:32 AM
A interface defines a contract you a class will implement. Generally interfaces should only have a small number of methods and be very specific.
As Andrew says you should do some reading, especially composition over inheritance.
Andrew FensterPosted Mar 13, 2011, 10:40 AM
(1) An interface has no code. It simply defines a list of public methods that any implementing class must include. An abstract class, on the other hand, can include code. That is, it can define a list of public methods, and then it can also have code to implement some or all of these. So classes that inherit from the abstract class start out with a basic set of code.
(2) Your class can inherit from only one class. However it can implement any number of interfaces.
You should devote some time to reading about abstract classes, interfaces and inheritance. A few hours of reading will do you a tremendous amount of good.