Using return;
in a void stops further execution, so working it into the code is as simple as this;
void print()
{
if(projectName == null || projectName == string.Empty)
return;
MessageBox.Show(projectName);
}
This will prevent the execution of MessageBox.Show(projectName);
if the conditions projectName == null || projectName == string.Empty
are not met.