Mid From PDF Collections C# Collections

How would you implement a generic collection in C# for a custom object?

Short answer: Define your custom object class. Create a collection class that holds objects of that type using generics or directly. Example: public class Employee

Example code

{
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.

Real-world example (ShopNest)

Prefer List<Order> over ArrayList in ShopNest. Generics catch type mistakes at compile time and avoid boxing when you store ints or decimals.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details