调用基于继承的方法调用也会返回吗?

mrb*_*lah 0 c# asp.net

说我的基本方法如下:

public int GetCount() {.....}
Run Code Online (Sandbox Code Playgroud)

现在我继承了GetCount的类,并执行:

public new int GetCount()
{
  int count = base.GetCount();

  count += 1;


  return count;

}
Run Code Online (Sandbox Code Playgroud)

调用base.GetCount()会在增量之前返回吗?(这似乎是我正在经历的)

Jar*_*Par 5

不,不会.调用base.Count与从方法返回相比没有任何其他方法调用.

在普通的C#方法中(不包括迭代器和异常进程终止),只有3种方法可以保留方法

  • 明确要求退货
  • 执行超出了void返回方法的代码路径中的最后一条指令
  • 函数或被调用函数中的抛出异常到达当前方法并且未处理