返回

MSDN:return 语句终止它出现的方法的执行,并将控制权返回给调用方法。它还可以返回一个可选值。如果方法是 void 类型,则可以省略 return 语句。

public int Sum(int valueA, int valueB)
{
    return valueA + valueB;
}

public void Terminate(bool terminateEarly)
{
    if (terminateEarly) return; // method returns to caller if true was passed in
    else Console.WriteLine("Not early"); // prints only if terminateEarly was false
}