! Operator
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

! Operator (C# Reference)

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.

User-defined types can overload the ! operator (see operator).

class MainClass4
{
    static void Main()
    {
        Console.WriteLine(!true);
        Console.WriteLine(!false);
    }
}
/*
Output:
False
True
*/
Show:
© 2016 Microsoft