How would you implement a generic collection in C# for a custom object?
- Define your custom object class.
- Create a collection class that holds objects of that type using generics or directly.
Example:
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
}
public class EmployeeCollection : Collection<Employee>
{
// You can add custom methods specific to Employee collection
here
}
Or simply use List<Employee> directly for flexibility.