Below is my code:
int a = 4;
if (a > 3)
{
Label1.Text = "Hello";
}
else
{
Label1.Text = "Hi!";
}
//Alternate for if-else
Label1.Text = (a > 3) ? "Hello" : "Hi!";
As we know, both if-else and alternate for if-else produce the same result. I was wondering if I would have more than one statement. For instance
int a = 4;
if (a > 3)
{
Label1.Text = "Hello";
Label2.Text = "How are you?";
}
else
{
Label1.Text = "Hi";
Label2.Text = "How do you do"";
}
So, is there an alternative for this? I'm sure there is something that C # offers that I can use. Thanks at Advance.
PS I'm new to C #
source
share