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 8483953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:14:56+00:00 2026-06-10T20:14:56+00:00

The question maybe a little confusing, but it’s hard to make clear this question

  • 0

The question maybe a little confusing, but it’s hard to make clear this question in a subject title.

I have method declared and implemented like this:

public IList<string> GetBookTitles()
{
    IList<string> bookTitles = new List<string>();
    // do something to populate the bookTitles list.
    return bookTitles;
}

Why can’t I pass the result of this method to a List<string>? After all, List<string> is a kind of IList<string>.

  • 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-10T20:14:57+00:00Added an answer on June 10, 2026 at 8:14 pm

    Well, for starters, just look at the members of IList and compare it with List. List has methods that an IList doesn’t. (List has a BinarySearch method that IList doesn’t, just as a single example.)

    Arrays also implement IList, as an example. An array however is not a List, so you can’t, and shouldn’t, be able to pass a string[] to a method that accepts a List<string>.

    You have a few possible solutions. One would be to just change your method to return a List<string> rather than an IList<string> (that’s what I’d suggest). If that’s what you really need then you shouldn’t be restricting the return type to IList<string>. Another (poorer) option would be to cast the result back to a List<string> before passing it to the next method, since you happen to know that it’s what the underlying type really is.

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

Sidebar

Related Questions

It maybe a little naive question but I have been trying to understand how
maybe this question is a little silly, but is it possible to load multiple
Maybe this is a little unconventional question but I'd like to hear an answer
Maybe the title is a little misleading and question could be too, but I'm
Maybe this question is a little far-fetched but i'll give it a shot.. Can
Maybe the question title is a little confusing, so I'll try to clarify things
maybe this question is a little too general but maybe someone has experience the
maybe this question is a little basic, but I'm reading the official docs in
Maybe my question is very basic, but regretfully I have very little experience with
OK, that question sounds maybe a little confusing so I'll try to explain it

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.