In my BL (there will be a public API), I use ICollection as return types in my search methods, for example:
public static ICollection<Customer> FindCustomers() { Collection<Customer> customers = DAL.GetCustomers(); return customers; }
Note the use of ICollection instead of Collection <>.
Now in my GUI, I need to return the results to Collection, for example:
Collection<Customer> customers = (Collection<Customer>)BL.FindCustomers();
This is because I need to use some special Collection <> methods in my returned list, which I cannot do with ICollection <>.
Is this the right use? Or should I just change the return type from Collection <> instead to ICollection <> to avoid this casting?
Secondly, I did not use IEnumerable, because it is more general than ICollection, and does not even have simple properties such as Count. And I really don't see the point in generalizing return types here. Did I miss something important?
source share