Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.

How does the .Max(...) work in LINQ? What will be the result of the following code?

var result = new[] { "hello", "world", "factory", "x" }.Max(p => p.Length);

Experience Level: Junior



The transform function p => p.Length will be executed on evey element of the array and the Length of the element will be identified. The biggest length will then be returned.

The value of the variable result will be 7.


No Comments Yet.
Be the first to tell us what you think.