I have an expression and 2 ways of splitting it:
List<string> list =
collection.Select(
control => SearchForControl(
control, someOtherParameters)).Select(
customControl => customControl.InnerText).ToList();
List<string> list = collection.
Select(control => SearchForControl(control, someOtherParameters)).
Select(customControl => customControl.InnerText).ToList();
What is more readable/better?
Where to put dots in the second case: at the beginning or end of the line?
I think pretty much everyone would consider the second to be more readable, since it justifies the query operations (
Select,Where, etc) prettily one below the other.For the dots, I would place them at the start of the line like this:
The reason is that it’s easier to copy/paste lines from or to this expression without breaking the syntax.