Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27031

VS 2008 Removing objects from a collection

$
0
0
Hi ! I'd like to ask you for a little help !
I have a collection filled with my user-defined objects . Adding items to it was easy , but now I want to remove some of them . How can I do it ?
Looking in the Help files , I found out that one can use the "Key" of the object to remove an object like this :
MyCollection.Remove("Key value of the object")
The problem is that my objects were added into the collection with no Key set :( ...
However , if the above is the only way to remove the desired objects , then I am thinking of setting now their Keys . Is this possible ?
All of my objects have a string property called MyName (for example MyObject.Myname = "Bla bla bla") . So I wonder if I could set their Keys to be identical to their MyName property . That would make them unique in the collection (by both MyName property and - now - by their Key) and thus I think I could proceed on to removing them with the code specified at the beginning . However I don't know how I should set their Keys :( ...
Of course if there is some other method , I'd be glad to hear !

Viewing all articles
Browse latest Browse all 27031

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>