if(expression) should be boolean in C#
The expression in an if statement must be enclosed in parentheses. Additionally, the expression must be a Boolean expression. In some other languages (notably C and C++), we can write an integer expression, and the compiler will silently convert the integer value to true (non-zero) or false (0) C# does not support this behavior, and the compiler reports an error if we write such an expression. If we accidentally specify the assignment operator, =, instead of the equality test operator, ==, in an if statement, the C# compiler recognizes your mistake and refuses to compile our code. For example: int seconds; ... if (seconds = 59) // compile-time error ... if (seconds == 59) // ok Accidental assignments were another common source of bugs in C and C++ programs, which would silently convert the value assigned (59) to a Boolean expression (with anything nonzero considered to be true), with the result that the code following the if sta...