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

The Archive Base Latest Questions

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

The MSDN article doesn’t really explain this. List<MyObject> FirstList = new List<MyObject>(); // Add

  • 0

The MSDN article doesn’t really explain this.

List<MyObject> FirstList = new List<MyObject>();
// Add items to FirstList.
List<MyObject> SecondList = new List<MyObject>(FirstList.AsReadOnly());
// Is SecondList a read-only collection?
  • 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-18T10:51:21+00:00Added an answer on May 18, 2026 at 10:51 am

    No, the second list is not read-only, it’s still a List generated from an IEnumerable<T> (specifically an ICollection<T> here). The .AsReadOnly() method just gives a ReadOnlyCollection<MyObject>, but we’re not modifying that collection when messing with the second list.

    Instead, you’ve created a new List<MyObject> with its members that is editable (via the List<T>(IEnumerable<T>) constructor). This does the generation like any other IEnumerable<T> source that’s an ICollection<T>, it performs a .CopyTo() underneath.

    In the case of a ReadOnlyCollection<T> (which implements ICollection<T>), it’s calling .CopyTo() on the original IList<T> underneath that it was from, so basically what you have is the same as:

    List<MyObject> FirstList = new List<MyObject>();
    // Add items to FirstList.
    List<MyObject> SecondList = new List<MyObject>(FirstList);
    

    ….as far as the second list is concerned. In other cases where the IEnumerable<T> passed to the constructor is not a ICollection<T>, it would iterate over the collection and .Add() each member instead…but it would still have no impact on the mutability of the new list and its members.

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

Sidebar

Related Questions

I have read the MSDN article on MVVM and I am not really convinced.
I read the msdn article about disposing objects in http://msdn.microsoft.com/en-us/library/ee557362(office.14).aspx now I'm really confused
As per this MSDN article: W3C Extended Log File Format (IIS 6.0) It says
I've followed the instructions in this MSDN article: http://msdn.microsoft.com/en-us/library/dd206945.aspx Is it possible to call
Is the advice given in this oft-cited MSDN article still considered sound for converting
This article on MSDN states that you can use as many try catch blocks
Could you give a bullet list of practical differences/implication? I read relevant MSDN article,
The MSDN article on String Basics shows this: string str = hello; string nullStr
This msdn article -- http://msdn.microsoft.com/en-us/library/bb219746(VS.85).aspx#Disabling_Accessibility_Shortcut_Keys -- provides information for C++ programmers on how to
I was following this article: http://msdn.microsoft.com/en-us/library/aa902637%28v=sql.80%29.aspx and my query for distinct count looks like

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.