Are setters required for collection type properties?
class Company
{
private IList<Customer> customers;
public IList<Customer> Customers
{
get { return customers; }
set { customers = value; }
}
}
class Company
{
private readonly IList<Customer> customers = new List<Customer>();
public IList<Customer> Customers
{
get { return customers; }
}
}
When do I use Type 1 vs Type 2? Wouldn't that be if I initialized the List and used readonly client properties? how inCompany.Customers.Add(new Customer)
What is the best practice regarding providing setters for collection type properties?
source
share