我有一种情况,我调用层叠样式的函数/方法。请参阅以下示例以了解说明和问题。我希望我知道这种情况的一些技术词汇。人们会更容易理解我在说什么。调用层次结构问题
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()'? –
请在代码块外面移动问题......现在不可能读取它。 –