DialogResult dialogResult = MessageBox.Show("Question", "Caption", MessageBoxButtons.YesNo); if(dialogResult == DialogResult.Yes) { //do something } else { //do something else }