从另一个程序退出原始功能

时间:2015-07-03 00:26:45

标签: c# function procedure

C#中有没有办法从另一个程序中退出函数?

示例:

void myFunction()
{
    checkLogin();    //make sure a user is logged in
    doOtherStuff();  //continue with other stuff
}
void checkLogin()
{
    if(loggedIn==false)
    {
        exitOriginalFunction(); // exit myFunction
    }
}

1 个答案:

答案 0 :(得分:1)

void myFunction()
{
    if(!checkLogin())
       return;    //make sure a user is logged in
    doOtherStuff();  //continue with other stuff
}
void checkLogin()
{
    if(loggedIn==false)
    {
        return false; // exit myFunction
    }
    return true;
}