ReSharper 2024.1 Help

Code inspection: Redundant control flow jump statement

If control flow does not change after you remove jump statements, such as return; or goto, these statements are redundant.

For example, 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 removing it.

public void WriteObj(object obj) { ArgumentNullException.ThrowIfNull(obj); Console.WriteLine(obj.ToString()); return; }
public void WriteObj(object obj) { ArgumentNullException.ThrowIfNull(obj); Console.WriteLine(obj.ToString()); }
Last modified: 19 June 2024