On Mar 19, 12:20 pm, Mike P <mike.p...@gmail.comwrote:
I'm pretty new to OOP and I'm just starting looking at generics and
collection classes. I understand why I might want to create a business
class, but can somebody please explain to me the reasons behind creating
collection classes?
Many thanks,
Mike
*** Sent via Developersdexhttp://www.developersdex.com***
You may want to create a custom collection class if there are
operations that make sense to exist on a collection of a specific
type. Since you can't add properties or methods to an existing class
you'll have to subclass or create a brand new class. For example, if
you have an Account business entity then it might make sense to have
an AccountCollection class where you could define a TotalBalance
property that would return the net balance of all contained accounts.
In the pre 2.0 days it was common to create a custom collection to
strongly type its contained items. But, with generics that's no
longer necessary.