Complete the code to declare a list that can store integers.
List<[1]> numbers = new List<[1]>();
string instead of int for numbers.We use int to create a list that stores integers.
Complete the code to create a generic method that returns the default value of any type.
public [1] GetDefaultValue<T>() { return default(T); }
void as return type when the method returns a value.int instead of the generic type.The method returns a value of type T, so the return type must be T.
Fix the error in the generic class declaration.
public class Box<[1]> { public T Value; }
var as a type parameter.The generic type parameter must be declared as T to match the usage inside the class.
Fill both blanks to create a generic method that swaps two variables.
public void Swap<[1]>(ref [2] a, ref [2] b) { [2] temp = a; a = b; b = temp; }
int instead of the generic type.The generic type parameter is T, and the variables use type T to swap any type.
Fill all three blanks to create a generic dictionary comprehension that filters entries with values greater than zero.
var filtered = [1].Where(kv => kv.Value [2] 0).ToDictionary(kv => kv.[3], kv => kv.Value);
We filter the dictionary data for values greater than zero and create a new dictionary using the keys.