Hi. I'm grappling with .NET Collections - great prospects but a milllion miles from VB6 Collection Object (why did they not include a similar abstract class to this??). Anyway, I've decided to use the NameObjectCollectionBase and build on that to create a strong typed Collection Class. It will be eaiser to explain my problem through an example i guess:
Suppose I have an Person Class (Two Properties: $FirstName and $SecondName) and the collection class is Persons and implements the usual Add, Item, Remove etc...The Key by which individuals are referenced is the concatanation of the First & Second names (i.e. MichaelJackson)
Dim People As New Persons
People.Add(New Person(David, Beckham)) 'Person Constructor allows both names as arguments...
People.Add(New Person(Victoria, Adams)) 'I do apologise...
So two members are added to the collection and can be referenced through the Item property via the keys (DavidBeckham and VictoriaAdams). Now imagine these two people get married, and, deciding to take her partners name, Victoria Adams becomes Victoria Beckham.
Changing her surname is no prob...
ame = "Beckham"
How though can I make changes on the Key which enables access through Item as the collection is niether aware or cares about the wedding and still thinks she's Miss Adams?
There used to be a trick to do this in VB6, its here if anyones interested http://archive.devx.com/free/tips/tipview.asp?content_id=3772
but is it possible in the .NET NameObjectCollectionBase where the Keys Collection is ReadOnly. Is this the right way to go about this type of problem at all?