我遇到了一些问题。虽然我正在慢慢进步并学习新知识,但我对C#仍然很陌生。
现在我有些困惑。我试图创建一个确认框,但它似乎不能像预期的那样工作。
以下是代码:
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Are you sure you want to exit off the application", "Are you sure?", MessageBoxButtons.YesNoCancel); //Gets users input by showing the message box
if (DialogResult == DialogResult.Yes) //Creates the yes function
{
this.Close(); //Exits off the application
}
else if (DialogResult == DialogResult.No)
{
//Does nothing
}