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

  • Home
  • SEARCH
  • 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 1014825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:18:31+00:00 2026-05-16T10:18:31+00:00

What is more efficient way to make methods return IList<T> or IEnumerable<T> ? IEnumerable<T>

  • 0

What is more efficient way to make methods return IList<T> or IEnumerable<T>?

IEnumerable<T> it is immutable collection but IList<T> mutable and contain a lot of useful methods and properties.

To cast IList<T> to IEnumerable<T> it is just reference copy:

IList<T> l = new List<T>();
IEnumerable<T> e = l;

To cast IEnumerable<T> to List<T> we need to iterate each element or to call ToList() method:

IEnumerable<T>.ToList(); 

or may pass IEnumerable<T> to List<T> constructor which doing the same iteration somewhere within its constructor.

List<T> l = new List<T>(e);

Which cases you think is more efficient? Which you prefer more in your practice?

  • 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-05-16T10:18:32+00:00Added an answer on May 16, 2026 at 10:18 am

    As far as efficiency is concerned both are interfaces so the efficiency will depend on the actual concrete class you are returning. As a rule of thumb you should always return the type that’s highest in the object hierarchy that works for the consumers of this method. In your case IEnumerable<T>. If the consumers of the class need to add elements, access elements by index, remove elements you are better off using an IList<T>.

    So as always in programming: it depends 🙂

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

Sidebar

Related Questions

Is there a more efficient way to list files from a bucket in Amazon
Is there are more efficient way than the following for selecting the third parent?
What is the more efficient way to create a web video chat ? What
I am looking for a more efficient way to do comparisons between all elements
A simple question: what is the more efficient way to access a db in
If I have a standard for loop is there a more efficient way to
Is there a more efficent way of doing this in terms of memory usage
Is there any more efficient,cleaner and shorter form for following: if($x==null or $y==null or
What is more efficient -- having a IDbTransaction in the .net code or handling
Is it better (more efficient, faster, more secure, etc) to (A) cache data that

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.