Back to Devexpress

CRR0014 - The variable is assigned twice in succession

coderushforroslyn-401453-static-code-analysis-analyzers-library-crr0014-variable-is-assigned-twice-in-succession.md

latest1.0 KB
Original Source

CRR0014 - The variable is assigned twice in succession

  • Feb 28, 2025

This analyzer detects variables which receive two assignments in succession.

csharp
bool isSelected = false;
isSelected = true;
vb
Private Sub SurroundingSub()
    Dim isSelected As Boolean = False
    isSelected = True
End Sub

How to Fix the Issue

Remove the first assignment.

csharp
bool isSelected;
isSelected = true;
vb
Private Sub SurroundingSub()
    Dim isSelected As Boolean
    isSelected = True
End Sub

How to Enable the Diagnostic

Choose Variable is assigned twice in succession in the Editor | Language | Code Analysis | Code Issues Catalog options page and check the Enabled checkbox.

See Also

Suppress Analyzers