The logical negation operator (!) is a unary operator that negates its operand. It is defined for bool and returns true if and only if its operand is false.
! expr
Where:
User-defined types can overload the ! operator (see operator).
// cs_operator_negation.cs
using System;
class Test
{
public static void Main()
{
Console.WriteLine(!true);
Console.WriteLine(!false);
}
}
False True
C# Operators |