I was wondering if in c# there was kind of like an if and else statement for methods like an example would be
private void button_click(object sender, EventArgs e)
{
if the ComputerSelectionmethod runs and executes don't execute the FindOpenCellCols method below
{
ComputersSelection();
FindOpenCellCols();
}
}
You can do something like this:
bool control = true;
try
{
ComputersSelection();
}
catch (Exception)
{
control = false;
}
if(!control) FindOpenCellCols();
I assume you mean runs and successfully executes by "runs and executes" .
If you change the control
variable to false
in catch
body, exception
may have thrown in last lines of code in that case ComputersSelection()
method's most part is executed and still FindOpenCellCols()
would be executed. Try the below code
public bool control = true;
ComputersSelection()
{
.......
code;
.......
control = false;
}
if(control)
{
FindOpenCellCols();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.