我有这样的事情:
static int cantryagain=0;
private void myfunction(){
if (cantryagain==0)
{
if(variableA=1)
{
//do my stuff
//ta daaaa
}
else
{
//do something magical that will help make variableA=1 but
//if the magic doesnt work i only want it to try once.
tryagain();
}
}
}
private void tryagain
{
myfunction();
cantryagain=1; //to make sure the magic only happens once, but
//obviously it never gets here as it does
//myfunction again before it ever can...
}
我知道这段代码超级蹩脚。我对 c# 还很陌生。
我怎么能正确地做出这样的事情?