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

Why LINQ is needed 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 declare a list of integers.

C Sharp (C#)
List<int> numbers = new List<int> [1];
Drag options to blanks, or click blank then click option'
A[]
B()
C{}
D<>
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets instead of parentheses.
Using curly braces without initialization.
2fill in blank
medium

Complete the code to filter numbers greater than 5 using LINQ.

C Sharp (C#)
var filtered = numbers.Where(n => n [1] 5);
Drag options to blanks, or click blank then click option'
A<
B==
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator instead of greater than.
Using equality operator which filters only numbers equal to 5.
3fill in blank
hard

Fix the error in the LINQ query to select names starting with 'A'.

C Sharp (C#)
var result = names.Where(name => name.[1]("A"));
Drag options to blanks, or click blank then click option'
AStartsWith
BstartWith
CstartsWith
DStartwith
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect casing for method name.
Misspelling the method name.
4fill in blank
hard

Fill both blanks to create a dictionary from a list using LINQ.

C Sharp (C#)
var dict = people.ToDictionary([1] => [2].Id);
Drag options to blanks, or click blank then click option'
Aperson
Bp
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the lambda expression.
Using variable names not declared in the lambda.
5fill in blank
hard

Fill all three blanks to select and order names using LINQ.

C Sharp (C#)
var orderedNames = people.Select([1] => [2].Name).OrderBy([3] => [3]);
Drag options to blanks, or click blank then click option'
Aperson
Bp
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in the two lambda expressions.
Using variable names that are not declared.