Are setters necessary for Collection Type Properties
//Type 1
class Company
{
private IList<Customer> customers;
public IList<Customer> Customers
{
get { return customers; }
set { customers = value; }
}
}
//Type 2
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 it suffice if I initialize a List & use readonly property Customers ? as in Company.Customers.Add(new Customer)
What is the best practice with respect to providing setters for collection Type properties?