S2761 — Doubled prefix operators "!!" and "~~" should not be used

Language
C#
Type
Bug
Severity
Major

Why is this an issue?

The repetition of a prefix operator (!, or ~) is usually a typo. The second operator invalidates the first one.


int v1 = 0;
bool v2 = false;

var v3 = !!v1; // Noncompliant: equivalent to "v1"
var v4 = ~~v2; // Noncompliant: equivalent to "v2"

↑ Back to top