This small snippet should get you started on what you are after.
DialogResult dr = MessageBox.Show("Are you sure you want to exit?", "Exit Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == System.Windows.Forms.DialogResult.Yes)
{
this.Close();
}