Abstract Classes

A method must be overridden
cannot be instantiated
advantage is that it enforces certain hierarchies for all the sub classes
can provide complete, default code and/or just the details that need to be overridden
advantage is that it allows implementations to share common code


Interfaces

Interfaces
An abstract modifier introduces a new virtual method but does not provide an implementation for it.
An abstract method is only allowed in an abstract class.
The implementation must be implemented in a derived class.
An abstract modifier is also a virtual modifier by default [[copy and paste from classes top level page]]


Interface MyInterface 
{
   void method_Name();
}
public class BaseClass : MyInterface
{
   public abstract public void method_Name(); }

public class DerivedClass : BaseClass
{
   public override void method_Name()
   {
      //implementation
   }
}


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext