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 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

This MSDN article stated that: processors are free to reorder this code internal static
According this MSDN article HttpApplication .EndRequest can be used to close or dispose of
I've found this MSDN article that explains how to monitor processes and services with
I'm building a Windows service and following this MSDN article , but I'm stuck
I have been playing with the demo code from this msdn article by Jeffrey
Some 4 years back, I followed this MSDN article for DateTime usage best practices
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
From the MSDN article on STAThread: Indicates that the COM threading model for an
I was reading the MSDN article about how to implement IDisposable and I am

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.