An abstract class can be inherited by another class, and require people to override the abstract functions, abstract properties, etc.
An interface also can be implemented by another class, also require people to implement the functions, properties, indexers, etc.
The only different I found is Visual Studio is smart enough to auto-generate the necessary members of this interface.
So, what’s the different?
thanks you~
In .NET, classes are limited to single inheritance but can implement any number of interfaces. If you inherit from an abstract class, that’s the only one you can use. It may not be a big deal, but it would prevent you from perhaps inheriting from MarshalByRefObject down the road, as an example.
Also, the behavior defined by an abstract class is limited to the classes that inherit from it. On the other hand, behaviors defined by interfaces (IDisposable, IPrintable, etc.) can be applied across class hierarchies.