Remove an element from an array
You should be able to simplify that whole inner loop with a simple Where extension:

If you have the equality operator implemented:

baseClass obj = cognosGroup.members.value[y];
cognosGroup.members.value = cognosGroup.members.value.Where(x =&gt; x != obj).ToArray()


Or use the index option:

cognosGroup.members.value = cognosGroup.members.value.Where((x,i) =&gt; i != y).ToArray()


Another option is to store the data in a List&lt;baseClass&gt; instead and use the Remove or RemoveAt extension.