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";
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.