ReSharper 2025.3 Help

Code inspection: Duplicated 'switch' arms

This inspection detects duplicate switch arms within switch expressions or statements where the labels differ, but the resulting values are identical. These cases may indicate redundancy in your code and could be simplified to make the logic clearer and more concise.

public string GetCategory(int value) => value switch { 1 => "Low", 2 => "Medium", 3 => "Medium", // Duplicate 'switch' arms 4 => "High", _ => "Unknown" };
public string GetCategory(int value) => value switch { 1 => "Low", 2 or 3 => "Medium", // Merged duplicate values 4 => "High", _ => "Unknown" };

In the example above, the arms for 2 and 3 both return the same value, "Medium". These arms can be merged into a pattern to reduce redundancy and improve the readability of the switch expression.

Merging duplicated arms will help to maintain clean, understandable code and make the intent of the switch statement or expression clearer.

15 July 2025