Log in

View Full Version : C# boolean operators?


Never_Forget
July 31st, 2009, 03:21 PM
So I looked them up on the internet, but they were for console, i need to be able to use the OR operator to shorten the following code into 1 'if', because at the minute if both statements are true, then it opens form2 twice and fails to close form1.

An alternative would be to tell me how to skip the rest of the event, like VB.NET's 'Exit Sub'?

private void Form1_Load(object sender, EventArgs e)
{


if (Settings1.Default.Username == "");
{

this.Hide();
Form2 create = new Form2();
create.Show();



}
if (Settings1.Default.Password == "") ;
{

this.Hide();
Form2 create = new Form2();
create.Show();




}
}

It's reading from a settings file, to determine whether a Username and Password has been set. I'm well aware of how to write to the settings file and save it.

Thanks!

EDIT: I forgot to say, even though it should be obvious, that this is a Windows Form Application.

EDIT2: Done it, I forgot double-brackets :S