Logical NOT (!) Expression Summary Negates an expression. Syntax !expression Parameters expression Any legal expression. Description The logical NOT (!) operator negates an expression. Therefore, if an expression evaluates to true, this operator applied to the expression will return false; if an expression evaluates to false, this operator applied to the expression will return true. 1234!true; // false!false; // true!( 5 > 3 ); // false!( 5 == 1); // true Inequality (such as comparing if x does not equal y) can also be checked by using the inequality (!=) comparison and strict inequality (!==) comparison operators. Usage in Conditional Statements The logical NOT operator is commonly used in conditional statements, such as if statements, to test if conditions are true or false. For example: 123456import System; bool x = false;if (!x) { Console.log("'x' is false");} See Also Logical AND (&&) Operator Logical OR (||) Operator if statements Inequality (!=) Comparison Operator Strict Inequality (!==) Comparison Operator Share HTML | BBCode | Direct Link