Text of codeql.github.com › codeql-query-help › csharp › cs-self-assignment as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Self-assignment — CodeQL query help documentation

CodeQL query help documentation » CodeQL query help for C# » Self-assignment ¶ ID: cs/self-assignment Kind: problem Security severity: Severity: error Precision: high Tags: - quality - reliability - correctness Query suites: - csharp-code-quality.qls - csharp-security-and-quality.qls Click to see the query in the CodeQL repository Assigning a variable to itself is redundant and often an indication of a mistake in the code.

Recommendation ¶ Check the assignment carefully for mistakes. If the assignment is truly redundant and not simply incorrect then remove it. Example ¶ In this example the programmer clearly intends to assign to this.i but made a mistake. class SelfAssignment { private int i ; public SelfAssignment ( int i ) { i = i ; } } © GitHub, Inc. Terms Privacy