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

后端 未结 9 1132
误落风尘
误落风尘 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 00:48

    If you have the same member in class and it's super class, the only one way to call member from super class - using base keyword:

    protected override void OnRender(EventArgs e)
    {
       // do something
    
       base.OnRender(e);
    
       // just OnRender(e); will bring a StakOverFlowException
       // because it's equal to this.OnRender(e);
    }
    

提交回复
热议问题