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

Where clause filtering in C Sharp (C#) - Interactive Code Practice

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

Complete the code to filter users with age greater than 18.

C Sharp (C#)
var adults = users.Where(u => u.Age [1] 18);
Drag options to blanks, or click blank then click option'
A>
B==
C<
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will select users younger than 18.
Using '==' will select only users exactly 18 years old.
2fill in blank
medium

Complete the code to filter products with price less than or equal to 100.

C Sharp (C#)
var affordable = products.Where(p => p.Price [1] 100);
Drag options to blanks, or click blank then click option'
A<=
B==
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' or '>=' will select expensive products, not affordable ones.
Using '==' will select only products priced exactly 100.
3fill in blank
hard

Fix the error in the code to filter orders with status 'Completed'.

C Sharp (C#)
var completedOrders = orders.Where(o => o.Status [1] "Completed");
Drag options to blanks, or click blank then click option'
A<
B!=
C==
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' selects orders not completed.
Using '>' or '<' does not work for string comparison here.
4fill in blank
hard

Fill both blanks to filter employees older than 30 and in the 'Sales' department.

C Sharp (C#)
var salesTeam = employees.Where(e => e.Age [1] 30 && e.Department [2] "Sales");
Drag options to blanks, or click blank then click option'
A>
B==
C<
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for age will select younger employees.
Using '!=' for department will exclude 'Sales' employees.
5fill in blank
hard

Fill all three blanks to filter books published after 2000, with more than 300 pages, and author is 'Smith'.

C Sharp (C#)
var selectedBooks = books.Where(b => b.Year [1] 2000 && b.Pages [2] 300 && b.Author [3] "Smith");
Drag options to blanks, or click blank then click option'
A>
B==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' or '<' will select older books or fewer pages.
Using '!=' for author will exclude books by Smith.