Inline if statement best practices in C#
When do we need to use inline statement in C# for best practices pls. For example, consider the if statement below with the condition of the if statement being writen on the same line. Why can we just write the break statement and omitting the curly braces pls. When is that considered a good practice? Say we have multiple if elseif statement, if one of the if else-if statement isn't an "inline" syntax, then every if statement shouldn't be inline ?
4 Replies
personal preference.
i personally don't even allow any statements without braces.
yep noted, I also prefer to be as explicit as possible with all the curly braces and each statement on their lines
i think convention says to always use { }, but personally i've never had issues when not using them, so one line return guard clauses for me are allowed to not have {}
csharp_prefer_braces = when_multiline