Tilde (~) Operator in the Enum definition in C#

Want to know what is the use of Tilde (~) symbol in C# especially when using enum definition?. Let’s have a look at the use of the Tilde (~) operator.

During a casual discussion with one of my friend , I came across a question on whether the tilde(~) symbol can be used in the enum definition as shown below.

Tilde (~) Symbol in the Enum definition in C#

public enum TypeData
    All = ~0,
    None = 0

Can tilde symbol be used as the enum values ? . Simple answer is Yes.

~0 results in the value -1