我有一種情況,我調用層疊樣式的函數/方法。請參閱以下示例以瞭解說明和問題。我希望我知道這種情況的一些技術詞彙。人們會更容易理解我在說什麼。調用層次結構問題
public static class test
{
private void button1_Click(object sender, RoutedEventArgs e)
{
if (Login("johndoe","password"))
{
if(checkForSomething("johndoe"))
{
DoOpenDashboard();
// Now it opens dashboard, it has several buttons.
// Each button does several different things
// On this example I am just giving you two level of hierarchy
// but in my actual program, there are 7 levels.
}
}
}
public static bool Login(string userid, string password)
{
//valid user
return true;
}
public static bool checkForSomething(string userid)
{
return true;
}
如果child方法運行成功,我該如何避免進程返回到上一個調用方法/函數?
例如,登錄方法正在調用checkForSomething("johndoe")
。如果通過checkForSomething("johndoe")
,則它將通過調用DoOpenDashboard打開儀表板窗口。此時我的流程不應該返回到checkforsoemthing,然後登錄。我希望這是有道理的。
你不能有一個包含它的類的名字相同的方法。 –
你的問題很難理解。你能不能僅僅爲你的類添加一個靜態變量或者實例成員來指示你的用戶是否已經登錄了,如果這個布爾值的值是false,你只能調用'Login()'? –
請在代碼塊外面移動問題......現在不可能讀取它。 –