An operator ~is a unitary bitwise complement operator that computes a bitwise complement. This means that it changes all the bits in its argument (0s become 1s and 1s become 0s). In this way,
int max = ~0;
which sets maxthe negation of the 32-bit value 0000 0000 0000 0000 0000 0000 0000 0000, which results in 1111 1111 1111 1111 1111 1111 1111 1111. Since we store this result in Int32, this is the same as -1.
Is it better to talk
int max = ~0;
or
int max = -1;
. max , 1, . max , (, int max = Int32.MinValue; , int max = list.Max();).