Code inspection: Redundant condition check before assignments
This inspection reports an if check that only prevents assigning a value that is already equal to the current one. The extra comparison is redundant because the same assignment can be made directly.
Example
class C
{
void SetValue(ref int current, int next)
{
if (current != next)
{
current = next;
}
}
}
Quick-fix
There is no dedicated quick-fix for this inspection. The usual fix is to remove the check and keep the assignment, unless the comparison is intentionally documenting behavior.
13 April 2026