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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:53:05+00:00 2026-05-25T17:53:05+00:00

I have a class that contains some properties, consisting of lists. These lists can

  • 0

I have a class that contains some properties, consisting of lists. These lists can be populated with some Sharepoint objects that can be fairly memory intensive.

I pass this class with its list properties through to my function like this:

public void InsertFixedLineItems(CacheBundle cb)
        {
//work here
        }

As you can see the type in question is called a CacheBundle, and at runtime its heavily populated.

For ease of use I want to localize the exact list properties further like this:

public void InsertFixedLineItems(CacheBundle cb)
         {
           List<XYZCacheItem> XYZCacheItems = cb.xyzCacheItems;
           List<YYYCacheItem> YYYCacheItems = cb.YYYCacheItems;
           List<ZZZCacheItem> ZZZCacheItems = cb.ZZZCacheItems; 
         }

My question is, during this assignment above is the code creating a copy of each property, essentially each collection. By doing so waste memory?

Or is the XYZCacheItems merely some kind of pointer to the cb.xyzCacheItems.

If it is not, is it possible to create a “pointer variable” so that if I update XYZCacheItems -> cb.xyzCacheItems gets updated too? At the same time use no extra (or very little) memory and have both assignments.

  • 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-25T17:53:06+00:00Added an answer on May 25, 2026 at 5:53 pm

    Lists are reference types, therefore are NEVER copied during assignment or while passing them into a function. XYZCacheItems points to the same object as cb.xyzCacheItems after the assignment, any changes to XYZCacheItems will appear in cb.xyzCacheItems as well.

    Variables of reference types, referred to as objects, store references to the actual data.

    From MSDN.

    You may also want to read some articles about differences between value and reference types (like this one). Understanding this is crucial to work with .Net languages efficiently.

    EDIT:

    Don’t mess up the terminilogy. Pointer is pointer (integer describing specific location in memory), reference is reference (identifier referring to specific managed object, which can be moved around in memory by the runtime, among other things).

    You CAN use classic C-like pointers in C#, but they have their drawbacks.

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

Sidebar

Related Questions

I have an abstract class foo that contains some properties and methods. I have
If I have a class that contains some properties and methods, and when a
I have a simple class that contains some general information about the current web
I have a class that contains data from some model. This class has metadata
I have a class that contains objects of two other classes. I need one
If I have a class that contains properties with private set and protected set
I have a class that contains a load of properties that contain results of
I have a simple class that contains the required properties for a request to
Let's say I have an instance of a class that contains dozens of properties.
I have a data class that return some objects from a wcf dataservice to

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.