Number of questions 1,751
Number of tests completed 247,601
Number of questions answered 3,708,424
Number of registered users 19,012
Sign In | Register
Skip Navigation Links
Question: string[] colors = { "green", "brown", "blue", "red" }; What's the output from the following? var query = from c in colors where c.Length == colors.Max (c => c.Length) select c; foreach (var element in query) Console.WriteLine (element);
Answer1: green followed by brown
Answer2: 5 followed by 5
Answer3: Compile-time error
Answer4: Exception is thrown
Answer5:
Answer: Compile-time error

Explaination: The variable, c, inside the subquery, conflicts with the outer query's iteration variable, so the compiler complains. Here's how to fix it: var query = from c in colors where c.Length == colors.Max (c2 => c2.Length) select c; The answer is then (green followed by brown).
Link:

Correctly answered: 423
Incorrectly answered: 945
Terms of Use
contact@quiznetonline.com Ver. 2.0.6783.38332