Consider the following two similar code examples.
One suggestion where.
bool validFactory
= fields
.Where(
fields => field.FieldType == typeof( DependencyPropertyFactory<T> ) &&
field.IsStatic )
.Any();
Two sentences where.
bool validFactory
= fields
.Where( field => field.FieldType == typeof( DependencyPropertyFactory<T> ) )
.Where( field => field.IsStatic )
.Any();
I prefer the second, as I consider it more readable and causes less formatting problems, especially when using automatic formatting. It is also clearer when posting comments next to individual terms (or even higher) in order to clarify the intention.
My intuition says that the second code example will be less efficient. Of course, I could write a simple test myself (and it will be if no one knows the answer). So far, I thought it was the perfect food for SO .; R
- Is more effective than the other?
- Is the compiler smart enough to optimize it?