Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

! 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).

// cs_operator_negation.cs
using System;
class MainClass 
{
    static void Main() 
{
        Console.WriteLine(!true);
        Console.WriteLine(!false);
    }
}
 
False
True
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.