Is there a way to make this code more efficient ?
if (includeRows != null && includeRows.Count > 0)
{
for (int i = aList.Count - 1; i >= 0; i--)
{
if (!includeRows.Exists(j => j == (i + 1)))
{
aList.RemoveAt(i);
includeRows.Remove(i + 1);
}
}
}
This is what i did , the aList contains objects not integers , so need the index of the object in the list.Not sure if the includeRows.Remove() would make it less or more efficient, includeRows was just changed to a HashSet.
for (int i = aList.Count - 1; i >= 0; i--) {
if (!includeRows.Contains(i + 1) )
{
aList.RemoveAt(i);
// includeRows.Remove(i + 1);
}
}