How to loop through list from the end


#1

I try to loop through List from the end by putting List.Reverse but it says the expression doesn’t produce a value. The list contains row numbers which to delete from datatable so i need to delete them from the bottom.


#2

@Timber

Why don’t you get the number of items in the list first, and then try to use a counter to access one by one and then reduce the count . Use a while or a do while loop to achieve this.

Let me know if it helps.


#3

List.Reverse does not return a value, that’s correct (Sub in VB.Net, void in C#). It modifies an existing object.
To use a void method, use Invoke Method:

If parameters are needed, at them to Parameters collection in properties.