Bird
0
0

Given a list of strings words, which LINQ query syntax correctly selects words starting with 'a' and orders them alphabetically?

hard🚀 Application Q15 of 15
C Sharp (C#) - LINQ Fundamentals
Given a list of strings words, which LINQ query syntax correctly selects words starting with 'a' and orders them alphabetically?
Avar query = from w in words where w.StartsWith("a") orderby w select w;
Bvar query = from w in words orderby w where w.StartsWith("a") select w;
Cvar query = from w in words select w where w.StartsWith("a") orderby w;
Dvar query = from w in words select w orderby w where w.StartsWith("a");
Step-by-Step Solution
Solution:
  1. Step 1: Understand LINQ clause order

    The correct order is 'from', then 'where', then 'orderby', then 'select'. var query = from w in words where w.StartsWith("a") orderby w select w; follows this order.
  2. Step 2: Verify filtering and ordering

    var query = from w in words where w.StartsWith("a") orderby w select w; filters words starting with 'a' and orders them alphabetically before selecting.
  3. Final Answer:

    var query = from w in words where w.StartsWith("a") orderby w select w; -> Option A
  4. Quick Check:

    where before orderby in LINQ [OK]
Quick Trick: Remember clause order: from, where, orderby, select [OK]
Common Mistakes:
MISTAKES
  • Placing 'orderby' before 'where'
  • Misplacing 'select' clause
  • Using wrong method syntax inside query

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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