i have some questions when watching this tutorial.
i wonder when i overwrite methods, how do i know if i need to call the base method?
public CustomerCollection(IEnumerable<Customer> customers, OMSEntities context) : base(customers)
also why do i need to do
protected override void InsertItem(int index, Customer cust)
{
this.context.AddToCustomers(cust);
base.InsertItem(index, cust);
}
protected override void RemoveItem(int index)
{
this.context.DeleteObject(this[index]);
base.RemoveItem(index);
}
what does the 2 lines in each method do? and why the need for such similar method. if i overwrite methods for delete and add why not update too?
You call the base method when you’re method is just additional functionality decorating what the base method does, you don’t call the base method when you are replacing it’s functionality wholesale.
And if you don’t know what the base method does, you wouldn’t be overriding it, so in knowing what it does and why you’re overriding it, you should be able to make this decision in accordance.