Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have two sets of collection objects (inherit from collection base) in a project. A property in collection A, depends on the index of an object in collection B.

Everything is great until items are removed from collection B because the indexes are changed and the property that depends on the index in collection B is now wrong.

I can fix this programmatically many different ways. But i wonder if maybe there is a collection defined in .NET that would be of use to fixing this problem. I am not searching these collections just constantly updating properties, in loops.

 

 

My best idea so far was to create an array named TrueIndex that holds the values of the real indexes an allows me to trick my program in a sense. I was considering a loop but i have graphics that depend on this and the loop would slow down everything considerably.

 

any ideas?

i'm not lazy i'm just resting before i get tired.
  • *Gurus*
Posted

Why would you make a property dependant on the index of something in a collection? Why not just make it dependant on the something itself?

 

You can use the collection's IndexOf function to get the index of the something in the collection whenever you like.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

The best way is to probably just go into System.Collection or System.Collections.Specialized namespaces with the object browser and take a look at the different collections. That way you can look at all their functionalities and the way they work, and determine which one will best fit your current project.

 

I'm not sure what Collection you're using (ArrayList?), but instead of removing the object perhaps you could set that location to null (c#) or nothing (vb).

 

Not really sure how you have things set up, so just giving ideas off the top of my head here. :)

Gamer extraordinaire. Programmer wannabe.
Posted
hmm, when i look at System.Collection i cant see any member objects in the object browser is this right?

Phil Price�

Visual Studio .NET 2003 Enterprise Edition

Microsoft Student Partner 2004

Microsoft Redmond, EMEA Intern 2004

Posted

Try looking under mscorlib for System.Collections

 

mscorlib -> System.Collections

in the object browser.

Gamer extraordinaire. Programmer wannabe.
Posted

well i thought about using 'nothing' but i kind of like the fact that my objects get smaller as they go... this makes the program run much faster in the long term (consider a chess engine that uses these values over and over)

i've done reading on them but didn't see specialized collections

i will look at specialized collections maybe that's my missing link

thanks for the info

i'm not lazy i'm just resting before i get tired.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...