Wednesday, February 21, 2018

Inheritance

public interface iBaseClass {
  void BaseClassMethod;
}


public class BaseClass : iBaseClass{
   // equivalent to private
   protected internal float accesibleToDerivedFloat = 0f;

   protected virtual void PrivateBaseClassMethod (){
      accesibleToDerivedFloat = 1f;
   }

   public virtual void BaseClassMethod ( //empty ) {}
}

====================================================

public interface IDerivedClass : IBaseClass{
}

public class DerivedClass : BaseClass, IDerivedClass{
   public override void PublicBaseClassMethod (){
      accesibleToDerivedFloat += 1f;
   }
}

No comments:

Post a Comment