ReSharper 2017.1 Help

Code Inspection: Redundant control flow jump statement

Using return; at the end of a void function is allowed by the compiler but it does not make the code better. A void function completes anyway when all its instructions have been executed, and control is transferred to the invoker of the method. So in this case the return; statement is redundant.

In the example below we have a redundant return; in a constructor and ReSharper suggests you to remove it.

Suboptimal codeAfter the quick-fix
public class MyClass { public MyClass(List<object> list) { _contents = list; Console.WriteLine(_contents.ToString()); return; } }
public class MyClass { public MyClass(List<object> list) { _contents = list; Console.WriteLine(_contents.ToString()); } }

See Also

Last modified: 4 July 2017