Write remove method at index based on iterator equivalent from java to c# -
i trying write equivalent method java. myiterator extends iterator.
public t remove(int index) { myiterator<t> = support.iterator();//returns iterator on sequence implementation int = 0; t e = null; while (it.hasnext() && < index) { e = it.next(); i++; } it.remove(); return e; }
how can write c# since there no defined method it.remove?
c#/.net iterators (ienumerator<t>
returned ienumerable<t>
) read-only forward iterators , not allow removing items underlying collection compared java's iterator.remove.
most collections support removing items index list<t>.removeat
close equivalent.
alternatively if want skip item during iteration - enumarable.skip
or enumerable.where
can option:
mysequence.where((item,id) => id != indextoskip)
Comments
Post a Comment