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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:02:09+00:00 2026-06-09T17:02:09+00:00

Obviously if I made a list and filled it with new object() then it

  • 0

Obviously if I made a list and filled it with “new object()” then it would be storing the memory for the object, but what if I made a list composed of only objects that were already defined, would this list essentially be a list of handles, or would all the data / memory copy to the list?

I just want to know so I can write code to be more clean, like if it’s actually copying the memory then I’ll do things differently because I don’t want it to make memory copies, that causes lag.

Does your answer also apply to arrays?

  • 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-09T17:02:10+00:00Added an answer on June 9, 2026 at 5:02 pm

    Obviously if I made a list and filled it with “new object()” then it would be storing the memory for the object,

    No, it would be storing a reference to the object. The value of any expression in C# is a value type value, a reference, or a pointer. Never an actual object.

    So this:

    List<object> objects = new List<object>();
    objects.Add(new object());
    

    is equivalent to this:

    List<object> objects = new List<object>();
    object foo = new object();
    objects.Add(foo);
    

    In both cases, the list will contain a reference to the object. This isn’t just the case for lists – it’s vital you understand it for assignment, parameter passing – anything where a reference is copied, basically. So as a simple example:

    StringBuilder sb1 = new StringBuilder();
    StringBuilder sb2 = sb1;
    // sb1 and sb2 now have the same value: a *reference* to an object
    sb2.Append("Hello");
    Console.WriteLine(sb1); // Prints Hello
    

    See my articles on value and reference types, and parameter passing for more information.

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

Sidebar

Related Questions

If I have an object that is made up of multiple jQuery objects, that
I have made a list that uses a list of dates as an index,
I've got a list of objects (probably not more than 100), where each object
I'm debugging some Python that takes, as input, a list of objects, each with
Obviously best-case is O(n), but apparently the worst-case is O(n 2 ), which I
Obviously it's early days, I do not know whether this is information that is
So obviously I am doing something wrong, but I just cannot seem to get
I have a div I've made resizable using jQuery UI. It works fine, but
I'm pretty new to java and really enjoying learning about it. I have made
NHibernate is preventing me from having a unique index that is made of a

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.