0
0
C Sharp (C#)programming~10 mins

Why advanced LINQ matters in C Sharp (C#) - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all even numbers from the list using LINQ.

C Sharp (C#)
var evens = numbers.Where(n => n [1] 2 == 0).ToList();
Drag options to blanks, or click blank then click option'
A%
B/
C*
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using division operator instead of modulo.
Using multiplication or addition operators.
2fill in blank
medium

Complete the code to order the list of strings by their length using LINQ.

C Sharp (C#)
var ordered = words.OrderBy(w => w.[1]).ToList();
Drag options to blanks, or click blank then click option'
ACount
BLength
CSize
DLength()
Attempts:
3 left
💡 Hint
Common Mistakes
Using Length() as if it were a method.
Using Count which is for collections, not strings.
3fill in blank
hard

Fix the error in the LINQ query to select distinct names from the list.

C Sharp (C#)
var distinctNames = names.[1]().ToList();
Drag options to blanks, or click blank then click option'
AUnique
BUniqueNames
CDifferent
DDistinct
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like Unique or Different.
4fill in blank
hard

Fill both blanks to create a dictionary with words as keys and their lengths as values, filtering words longer than 3 characters.

C Sharp (C#)
var dict = words.Where(w => w.[1] 3).ToDictionary(w => w, w => w.[2]);
Drag options to blanks, or click blank then click option'
A>
B<
CLength
DCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for filtering.
Using Count instead of Length for strings.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys, their original words as values, filtering words starting with 'a'.

C Sharp (C#)
var dict = words.Where(w => w.[1]('a')).ToDictionary(w => w.[2](), w => w.[3]);
Drag options to blanks, or click blank then click option'
AStartsWith
BToUpper
CToString
DLength
Attempts:
3 left
💡 Hint
Common Mistakes
Using Length instead of ToString for values.
Using wrong methods for filtering or converting case.