Complete the code to declare a generic interface named IRepository.
public interface [1]<T> { void Add(T item); }The generic interface is named IRepository to follow common C# naming conventions.
Complete the code to implement the generic interface IRepository for a class named Repository.
public class Repository<T> : [1]<T> { public void Add(T item) { /* implementation */ } }
The class Repository implements the generic interface IRepository with the same type parameter T.
Fix the error in the interface method declaration to make it generic.
public interface IRepository<T> { void [1](T item); }The method name Add matches the common naming convention for adding an item to a collection.
Fill both blanks to declare a generic interface with a method that returns an item by index.
public interface [1]<T> { T [2](int index); }
The interface is named IRepository and the method to get an item by index is commonly named Get.
Fill all three blanks to implement a generic interface with Add and Get methods in a class.
public class [1]<T> : [2]<T> { private List<T> items = new List<T>(); public void Add(T item) { items.Add(item); } public T [3](int index) { return items[index]; } }
The class Repository implements the interface IRepository and defines the method Get to retrieve items by index.