Complete the code to select all even numbers from the list using LINQ.
var evens = numbers.Where(n => n [1] 2 == 0).ToList();
The modulo operator % returns the remainder. Using n % 2 == 0 checks if a number is even.
Complete the code to order the list of strings by their length using LINQ.
var ordered = words.OrderBy(w => w.[1]).ToList();Length() as if it were a method.Count which is for collections, not strings.Strings have a property Length that gives their length. Use it without parentheses.
Fix the error in the LINQ query to select distinct names from the list.
var distinctNames = names.[1]().ToList();Unique or Different.The correct LINQ method to get unique elements is Distinct().
Fill both blanks to create a dictionary with words as keys and their lengths as values, filtering words longer than 3 characters.
var dict = words.Where(w => w.[1] 3).ToDictionary(w => w, w => w.[2]);
< instead of > for filtering.Count instead of Length for strings.We filter words longer than 3 using > 3 and use the Length property for values.
Fill all three blanks to create a dictionary with uppercase words as keys, their original words as values, filtering words starting with 'a'.
var dict = words.Where(w => w.[1]('a')).ToDictionary(w => w.[2](), w => w.[3]);
Length instead of ToString for values.We filter words starting with 'a' using StartsWith, convert keys to uppercase with ToUpper(), and use the original word as value with ToString().