Hi,
im getting an error
'Invalid term expression else'.

private void button1_Click(object sender, EventArgs e)
        {
            ClassLogin clgn = new ClassLogin();
            bool sts =clgn.Check(textBox2.Text, textBox1.Text);
            if (sts == true)
            {
                MessageBox.Show("OK");
                else
                MessageBox.Show("Your Username or password is incorrect");
                
            }

        }

WHY?

Do it like this:

if (sts == true)            
{                
MessageBox.Show("OK");    
}            
else   
{           
MessageBox.Show("Your Username or password is incorrect");             
}
private void button1_Click(object sender, EventArgs e)        
{            
ClassLogin clgn = new ClassLogin();            
bool sts = clgn.Check(textBox2.Text, textBox1.Text);            
if (sts == true)            
{               
MessageBox.Show("OK");
}
else
{
MessageBox.Show("Your Username or password is incorrect");             
}

The syntax for if else is

if (Condition)
  {
     txtName.Text="ravi Varma";
  }
else
  {
     txtName.Text="ravi kiran varma";
  }
This question has already been answered. Start a new discussion instead.