I heard goto is bad, so I ask someone in this site if my code is better using goto or other alternative    public FormMain()    {    // start of the apps    Start:        // show login form        FormLogin login = new FormLogin();        DialogResult dr = login.ShowDialog();        // cancel form loading if login form is canceled        if (dr == DialogResult.Cancel)        {            Load += (s, e) => Close();            return;        }        // login error        if (dr == DialogResult.No)        {            // back to start            goto Start;        }        // Initialize main form component        InitializeComponent();    }
Simple C# goto alternative
c#;beginner;winforms
You don't want to use goto in this case. Use a loop instead, like this:public FormMain(){    DialogResult dr;    do    {        // show login form        FormLogin login = new FormLogin();        dr = login.ShowDialog();        // cancel form loading if login form is canceled        if (dr == DialogResult.Cancel)        {            Load += (s, e) => Close();            return;        }    }    while(dr == DialogResult.No); // login error    // Initialize main form component    InitializeComponent();}