C#

C#

Made by DeepSource

Result of the bitwise operation is same as its operand CS-R1089

Anti-pattern
Critical
Autofix

The result of the specified bitwise operation is same as the operand supplied to the bitwise operator. It is possible that you meant to specify a different operand. It is recommended that you review the said bitwise operation to ensure it does what you need.

Bad Practice

var i = 4;

// Note: The entire bitwise operation is replaced with `i` if
// you choose to Autofix this issue.

Console.WriteLine(i & -1); // Result is 4, effectively `i`.
Console.WriteLine(i ^ 0);  // Result is 4, effectively `i`.
Console.WriteLine(i | 0);  // Result is 4, effectively `i`.

Recommended

var i = 4;

Console.WriteLine(i);
Console.WriteLine(i);
Console.WriteLine(i);