What really is the purpose of “base” keyword in c#?

后端 未结 9 1159
误落风尘
误落风尘 2020-12-08 00:42

Thus for used base class for some commom reusable methods in every page of my application...

public class BaseClass:System.Web.UI.Page
{
   public string Get         


        
9条回答
  •  不思量自难忘°
    2020-12-08 01:06

    Base is used when you override a method in a derived class but just want to add additional functionality on top of the original functionality

    For example:

      // Calling the Area base method:
      public override void Foo() 
      {
         base.Foo(); //Executes the code in the base class
    
         RunAdditionalProcess(); //Executes additional code
      }
    

提交回复
热议问题