Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:17:55+00:00 2026-06-11T05:17:55+00:00

For the List object, we have a method called Reverse() . It reverse the

  • 0

For the List object, we have a method called Reverse().
It reverse the order of the list ‘in place’, it doesn’t return anything.

For the IEnumerable object, we have an extension method called Reverse().
It returns another IEnumerable.

I need to iterate in reverse order throught a list, so I can’t directly use the second method, because I get a List, and I don’t want to reverse it, just iterate backwards.

So I can either do this :

for(int i = list.Count - 1; i >=0; i--)

Or

foreach(var item in list.AsEnumerable().Reverse())

I found it less readable than if I have an IEnumerable, just do

foreach(var item in list.Reverse())

I can’t understand why this 2 methods have been implemented this way, with the same name. It is pretty annoying and confusing.

Why there is not an extension called BackwardsIterator() in the place of Reverse() working for all IEnumerable?

I’m very interested by the historical reason of this choice, more than the ‘how to do it’ stuff!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:17:57+00:00Added an answer on June 11, 2026 at 5:17 am

    It is worth noting that the list method is a lot older than the extension method. The naming was likely kept the same as Reverse seems more succinct than BackwardsIterator.

    If you want to bypass the list version and go to the extension method, you need to treat the list like an IEnumerable<T>:

    var numbers = new List<int>();
    numbers.Reverse(); // hits list
    (numbers as IEnumerable<int>).Reverse(); // hits extension
    

    Or call the extension method as a static method:

    Enumerable.Reverse(numbers);
    

    Note that the Enumerable version will need to iterate the underlying enumerable entirely in order to start iterating it in reverse. If you plan on doing this multiple times over the same enumerable, consider permanently reversing the order and iterating it normally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method to find an object in a list in C++. Step
I have the following method and interface: public object ProcessRules(List<IRule> rules) { foreach(IRule rule
I have a a method like this : List < Object > getObjects(List<Integer> ids)
I have a method which compares two objects and returns a list of all
I have a list of System.DirectoryServices.ActiveDirectory.Domain objects gotten via this method. How do I
I have a List<Foo> , and a compare() method taking two Foo objects and
I have a Generic List object which hold below table as its own value.
I have an object list being loded from a database to a drop down
I have a List object and I want to remove the duplicated items but
Have a method with the following signature: def foo(self, bar, *uks): return other_method(..., uks)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.