[C#] If-else + Nested Message Box


โค้ด
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult resp;
            resp = MessageBox.Show("Have you ever used email before ?", "Email", MessageBoxButtons.YesNo);

            if (resp == DialogResult.Yes)
            {
                resp = MessageBox.Show("Have you ever met spam mail ?", "Spam Email", MessageBoxButtons.YesNo);
                if (resp == DialogResult.Yes)
                {
                    MessageBox.Show("You should install anti-spam program.");
                }
                else
                {
                    MessageBox.Show("Wow, you are lucky.");
                }
            }
            else
            {
                MessageBox.Show("You should try it.");
            }
        }
    }
}
Previous
Next Post »