What is an elegant way of writing this?
if (lastSelection != null)
{
lastSelection.changeColor();
}
else
{
MessageBox.Show("No Selection Made");
return;
}
changeColor()
is a void function and the function that is running the above code is a void function as well.
You can reduce clutter by reversing the condition:
if (lastSelection == null)
{
MessageBox.Show("No Selection Made");
return;
}
lastSelection.changeColor();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With