G
Guest
I've got a few problems of losing the values of items within an IDictionary
or ICollections based class.
In one case, I have a class that contains a hashtable that holds properties.
I have several instances of this class. I load the values for each instance
into a hashtable at the beginning by reading the information from an XML
file. I can see the count of the hashtable increase each time indicating
that the items are being added. I then add the list of my objects (each
containing its own hashtable) into a listview. When I try to retrieve my
objects from the listview, however, the items that were in the hashtable
previously are no longer there.
The same type of thing happens with lists. I have a type safe list that
inherits from Collectionbase. I have a main list of my objects, and from
that list I create two other lists, like this:
// Each list is a list if "Item" objects
MyList TrueList = new MyList();
MyList FalseList = new MyList();
foreach (Item a in myList)
{
if (a.IsTrue)
TrueList.Add(a);
else
FalseList.Add(a);
}
In the main list "myList" all of the properties are there, however if I say:
foreach (item a in TrueList)
{
if (myList.Contains(a))
return true;
}
true is never returned. When, in fact, if the count of TrueList is greater
than 0, it should always return true since the items came directly from
myList.
It works fine in the Full Framework app, but I've had problems with it in
myCF app.
Does anyone have any experience with this or any ideas of what to look at?
Thanks
-G
or ICollections based class.
In one case, I have a class that contains a hashtable that holds properties.
I have several instances of this class. I load the values for each instance
into a hashtable at the beginning by reading the information from an XML
file. I can see the count of the hashtable increase each time indicating
that the items are being added. I then add the list of my objects (each
containing its own hashtable) into a listview. When I try to retrieve my
objects from the listview, however, the items that were in the hashtable
previously are no longer there.
The same type of thing happens with lists. I have a type safe list that
inherits from Collectionbase. I have a main list of my objects, and from
that list I create two other lists, like this:
// Each list is a list if "Item" objects
MyList TrueList = new MyList();
MyList FalseList = new MyList();
foreach (Item a in myList)
{
if (a.IsTrue)
TrueList.Add(a);
else
FalseList.Add(a);
}
In the main list "myList" all of the properties are there, however if I say:
foreach (item a in TrueList)
{
if (myList.Contains(a))
return true;
}
true is never returned. When, in fact, if the count of TrueList is greater
than 0, it should always return true since the items came directly from
myList.
It works fine in the Full Framework app, but I've had problems with it in
myCF app.
Does anyone have any experience with this or any ideas of what to look at?
Thanks
-G