Reputation: 7223
if (some condition) ||
(some other condition)
{
// do something
}
The above format does not work. Says invalid expression "||"
.
Upvotes: 2
Views: 2304
Reputation: 160982
your brackets are off, should be:
if ((some condition) ||
(some other condition))
{
// do something
}
Upvotes: 5
Reputation: 32278
You're missing outside parentheses on your if
statement. e.g.
if ((some condition) || (some other condition))
{
// do something
}
Upvotes: 7
Reputation: 56408
if
statements in C# need to be entirely contained in a set of parentheses. Add another set around your two ||
ed expressions and that will work fine, even on two lines.
if ((some condition) ||
(some other condition))
{
// do something
}
Upvotes: 8