Collection indexes

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: songie D (anonymous_at_discussions.microsoft.com)
Date: 05/13/04


Date: Thu, 13 May 2004 01:51:04 -0700

If you remove an item from a collection (that is derived from CollectionBase and thus implements IList)
will the index property automatically 'shuffle' up one?
i.e. if of {0, 1, 2, 3} I delete item 2, then will I be left with {0, 1, 2} or {0, 1, 3} ?
Basically I am implementing a custom collection and wondered if I could rely on
the fact that for(int i=0; i<List.Count; i++) would always be an appropriate loop.