Code Inspection: Invert 'if' statement to reduce nestingLast modified: 21 March 2024tipYou can suppress this inspection to ignore specific issues, change its severity level to make the issues less or more noticeable, or disable it altogether.Consider the following code snippet:void PrintName(Person p) { if (p != null) { if (p.Name != null) { Console.WriteLine(p.Name); } } }As you can see, the if blocks encompass the whole body of the method. This presents an opportunity to make code more readable by getting rid of the nested scope as follows:void PrintName(Person p) { if (p == null) return if (p.Name == null) return; Console.WriteLine(p.Name); }