You want to know when to wrap long lines of C# code.
Use the following guidelines to help you decide where to insert a new line to split a long statement.
• Break a long line after a comma but before an operator. Beginning a new line with an operator makes it clear that it’s the result of statement splitting.
• Avoid wrapping a line in the middle of an expression, especially if in the middle of a parenthesized expression.
• Try to keep all items at a given nesting level on the same line.
• Don’t create excessively long lines if you later need to split them. Consider using temp variables to reduce expression complexity.
• Indent all wrapped lines by one tab.
// This is incorrect. A parenthesized expression is split, leaving an operator on the first line. result = DoWork(first, second * (third + fourth)); // Both of these are correct, but the second one is better. result = DoWork(first, second * (third + fourth)); result = DoWork(first, second * (third + fourth));