~ Operator (C# Reference)
The bitwise complement operator
~ is a unary operator that produces a bitwise complement of its operand by reversing each bit. All integer types support the
~ symbol is also used to declare finalizers. For more information, see Finalizers.
The following example demonstrates the usage of the
uint a = 0b_0000_1111_0000_1111_0000_1111_0000_1100; uint b = ~a; Console.WriteLine(Convert.ToString(b, toBase: 2)); // Output: // 11110000111100001111000011110011
User-defined types can overload the
C# language specification
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.