Bird
0
0

What will be the output of this LINQ query?

medium📝 Predict Output Q13 of 15
C Sharp (C#) - LINQ Fundamentals
What will be the output of this LINQ query?
int[] numbers = {1, 2, 3, 4, 5};
var result = from n in numbers where n > 3 select n;
foreach(var num in result) Console.Write(num + " ");
A4 5
B1 2 3 4 5
C3 4 5
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand the query condition

    The query selects numbers greater than 3 from the array {1,2,3,4,5}.
  2. Step 2: Identify numbers > 3

    Numbers 4 and 5 satisfy the condition n > 3.
  3. Final Answer:

    4 5 -> Option A
  4. Quick Check:

    Filter numbers > 3 = 4 5 [OK]
Quick Trick: Look for the 'where' condition filtering data [OK]
Common Mistakes:
MISTAKES
  • Including numbers equal to 3
  • Printing all numbers ignoring the condition
  • Assuming no output if condition is misunderstood

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes