ReSharper 2026.1 Help

Code inspection: Use deconstruction to swap variables

This inspection reports the classic three-step swap pattern that uses a temporary variable. When both swapped values can be safely evaluated as a tuple assignment, the swap can be written more directly with deconstruction.

Example

var temp = left; left = right; right = temp;
(left, right) = (right, left);

Quick-fix

Tuple-based swapping is shorter and avoids introducing a temporary variable whose only purpose is the swap.

30 March 2026