Which of these is more optimal? Does it matter which one you use?
If (condition is true)
{
MessageBox.Show("bad data");
return;
}
//mode code here
or
If (condition is true)
{
MessageBox.Show("bad data");
}
else
{
//mode code here
}
The two are functionally the same. Neither is actually superior to the other in terms of behavior or performance. The only real issue here is readability, and that will vary based on the specifics of the example and the programming team involved. So in short, pick whatever you want.
Note that your example should probably be a bit more complete for these assertions to hold true. It should really be comparing;
with: