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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:50:39+00:00 2026-05-28T20:50:39+00:00

Now, I know this might be a newbie question, but I always screws this

  • 0

Now, I know this might be a newbie question, but I always screws this up.

I have a list containing a bunch of objects, but then later in my code I query the list to modify one of the objects using LINQ.

Will this update the object inside the list as well or will I have to remove the old instance of the object from the list and then place the object I pulled out back into the list to make sure that the changed values are stored in the list? The list is just a simple List<MyObject>.

  • 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-28T20:50:40+00:00Added an answer on May 28, 2026 at 8:50 pm

    The vital thing to remember is that a list does not contain objects. It contains references to objects. So if you do:

    List<Foo> foos = GetListOfFooFromSomewhere();
    Foo foo = foos[0];
    foo.Name = "Some other name";
    

    there’s only one Foo object involved – but both the list and the local variable have a reference to that same object. Changes to the object don’t need to be “propagated” to the list, because the list doesn’t have that data in the first place.

    An analogy I sometimes use is this: if I give two people my home address on pieces of paper, and one of them paints my front door red, then if the other person goes to my house, they’ll see a red front door. The pieces of paper are distinct, but they don’t contain “my house” – they just contain a way of getting to my house. There’s only one house.

    (This is assuming Foo is a class, by the way. If you have a list of mutable structs, then the list really contains the data directly, not references. Personally I would avoid using mutable structs to start with.)

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

Sidebar

Related Questions

i know this question might be too easy, but i have no idea how
Now this may seem like a silly question, but I need to know how
This might be a simple question for those who know Spring, but since I
I know this might sound silly but I have no idea how to do
I know this might seem like a simple question, but its answer has been
I know this question might sound a little cheesy but this is the first
Now I know this basic question has been asked before, but I must be
So this might be an odd question, but I have a C# program that
I know that this might be a duplicate of this question but that was
this might be quite a newbie question, but i need to process a certain

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.