Strongly Typed Collection Problem

  • Thread starter Thread starter walterd
  • Start date Start date
W

walterd

Hi All

I have a class Persons that hold key/value pairs of Person class. My problem
is the following.
On the first screen I create an instance of Person, I then add a name and
surname and then add the class to class Persons ( I can add more than one
Person class on this screen). On the next screen I retrieve the Person I am
interested in and add Home Address or whatever I wish to add.
The problem starts when I call the Add method of the Persons class. The
value (Person that's been updated) is never stored or updated in the Persons
class.

public object Value
{
get{return this.mValue;}
set
{
if (this.mValue != value)
{
this.mValue = value;
}
}
}

Can some give some green light?
 
I sounds like you should really just have a Person class and use an indexer,
so you could then reference:

Person personBob = objPerson["Bob"];
// or
Person personBob = objPerson[0];

I may not fully understand what you are trying to accomplish. Is it possible
to post a working snippet of code??
 
The get/set below is not your problem...

You said that the updated value is never added to the collection.
(a) which collection object are you using? Hashtable?
(b) how are you indexing the value in the collection?
(c) you mention that you find the Person on the next screen, but you do not
mention if you try to update it, or overwrite it, or just add it again.
Could it be that your attempt to add it again is failing, and that you are
ignoring the error?

--- Nick
 
Back
Top