Here is a standard if … then statement in C# followed by a single line example. Using a single line if statement will reduce the number of lines of code.
if (dayOfTheWeek == "Tuesday")
{
lunchLocation = "Fuddruckers";
}
else
{
lunchLocation = "Food Court";
}
And the same example as a single line if … then statement.
lunchLocation = (dayOfTheWeek == "Tuesday") ? "Fuddruckers" : "Food Court";
Alex
Aug 27, 2014 — 7:25 am
Thank you, sir.
unknown
Sep 30, 2014 — 1:24 am
Thank you very much, this is really helpful.