I have a WPF form with a button which links to an avent handler. Before I do anything with the event, I want to check that some conditions are met, and if not, do nothing.
I can do this via a series of if statements nested within one another, but I think my code would be much cleaner if I could just check for some conditions at the beggining, and break out of the event if those conditions are met. Is there a way to do this?
e.g. I want to do something like
Is this possible to do? I was not sure what the command was to break out of a button press, I know that you can use break for loops, so is there a similar command for events?
Thanks
I can do this via a series of if statements nested within one another, but I think my code would be much cleaner if I could just check for some conditions at the beggining, and break out of the event if those conditions are met. Is there a way to do this?
e.g. I want to do something like
C#:
private void Button_Click(object sender, RoutedEventArgs e)
{
if (my_condition==true){break}
//continue the code if the if statement has not broken it
}
Is this possible to do? I was not sure what the command was to break out of a button press, I know that you can use break for loops, so is there a similar command for events?
Thanks