The if Statement Must Always Include a Boolean Expression

In C++, an if statement can use a conditional expression that resolves to a numeric value.  The statement following theif statement will execute when this expression resolves to any non-zero value.  This form of the if statement is not allowed in C#.
1
2
3
4
5
6
7
uint leaves = CountLeavesInBackyard();
 
// Works in C++, but is not allowed in C#
if (leaves)
{
    RakeLikeHeck();
}
Since the if statement must use a boolean expression in C#, we’d rewrite the code as:
1
2
3
4
if (leaves > 0)
{
    RakeLikeHeck();
}