J
jdn
I have a class which inherits from System.Collections.CollectionBase and
am having one heck of a time figuring the following out.
The point of the class is to hold objects of another class.
Specifically, I have an Identity class which holds various types of
information, and the other class is the Identities class. It's only job
is to hold a collection of Identity objects.
Since it inherits from CollectionBase, I know I shouldn't need to do
this, but I added a private member ArrayList called m_IdentityArrayList.
I have the following function to add an identity object:
public Identity Add(Identity objAddIdentity){
m_IdentityArrayList.Add(objAddIdentity);
return objAddIdentity;
}
I return the object in case I need to do something to it after adding
it, though I don't at the moment.
Here's the issue:
I add an Identity object. While in debug mode I can view its properties
just fine and everything looks okay. Then I add a second object. When
I look at the properties for the second Identity object after adding it,
it looks fine. But then I look at the first Identity object, and it now
has the properties of the second object, not its original properties.
If I add a third Identity object, then the properties of each Identity
object are only of the third object.
So, the collection seems to overwrite the properties of each already
existing object with the properties of the last one added.
What could I possibly be doing wrong?
jdn
am having one heck of a time figuring the following out.
The point of the class is to hold objects of another class.
Specifically, I have an Identity class which holds various types of
information, and the other class is the Identities class. It's only job
is to hold a collection of Identity objects.
Since it inherits from CollectionBase, I know I shouldn't need to do
this, but I added a private member ArrayList called m_IdentityArrayList.
I have the following function to add an identity object:
public Identity Add(Identity objAddIdentity){
m_IdentityArrayList.Add(objAddIdentity);
return objAddIdentity;
}
I return the object in case I need to do something to it after adding
it, though I don't at the moment.
Here's the issue:
I add an Identity object. While in debug mode I can view its properties
just fine and everything looks okay. Then I add a second object. When
I look at the properties for the second Identity object after adding it,
it looks fine. But then I look at the first Identity object, and it now
has the properties of the second object, not its original properties.
If I add a third Identity object, then the properties of each Identity
object are only of the third object.
So, the collection seems to overwrite the properties of each already
existing object with the properties of the last one added.
What could I possibly be doing wrong?
jdn