May 11th, 2010, 05:16 AM
[RESOLVED] Skip certain elements in an array?
Elements cannot be removed from an array. Is it possible to skip or hide particular items in an array by stating the element ID of the elements desired to be skipped? As far as I understand the method Skip() only skips the first element or elements, depending on how many you specified. Here is an example below of why I need to skip certain elements in the array:
I have considered using some form of two-dimensional arraylist,containing both the volume no and the volume content, enabling me to remove specified elements from the arraylist but I don't know what I can use....
public void MergeVolumes()
Volumes lVolumes = mWebService.getAllVolumes();
List<string> contents = new List<string>();
int count = lVolumes.Length; // Original value of count
int volumeOrder = 1; // First category of unknown number of categories
int ID = 0; // Element ID
// Add the content of all volumes of a book to a list<string> "contents" in chronological order
for (int i = 0; i < count; i++)
int volumeNo = lVolumes[ID].Number;
if (volumeNo == volumeOrder)
// Add content of the current volume to the list
// Skip this element each time
lVolumes.Skip(ID); // PROBLEM!
// Look for next volume now
// Keep looping till find the desired volume
// Once run through array once, rerun
if (ID == lVolumes.Length - 1)
// Reset to zero
ID = 0;
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!