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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:03:53+00:00 2026-06-18T07:03:53+00:00

I have a system where Object A can at will produce Object B .

  • 0

I have a system where Object A can at will produce Object B. One Object A can produce any number of Object B, and there are multiple Object A‘s.

It is useful in my program to know WHICH Object A produced which Object B (for various reasons). Currently, whenever an Object B is created, I just store the Object A that created it as a parameter inside Object B. But this doesn’t feel right to me.

Question 1: Is there a way to store simply a reference to the correct Object A inside the Object B, instead of the whole object? Or is that actually what’s happening anyways?

Question 2: Is doing it the way I am now inefficient for memory?

  • 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-18T07:03:55+00:00Added an answer on June 18, 2026 at 7:03 am

    Question 1:

    Yes it is possible. You can pass a reference to creator object e.g. by constructor. It could be also by public property setter or public field but I would recommend to use constructor.

    public class ObjectB
    {
        public ObjectA Parent {get; private set;}
    
        public ObjectB(ObjectA parent)
        {
            this.Parent = parent;
        }
    }
    
    public class ObjectA
    {
        private ObjectB GetNewObjectB()
        {
             return new ObjectB(this);
        }
    }
    

    Question 2:

    Object reference takes 4bytes/8bytes on 32bit/64bit OS. So you can roughly imagine the additional memory consumption and determine, if it is an issue for you (IMHO it would not be an issue for most of the applications).

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

Sidebar

Related Questions

I have a System.Web.Mvc.RazorView object which is strongly typed when in cshtml. Can I
Say I have a simple object which supports implicit casting to System.String public sealed
I am currently in the process of designing a system which will use multiple
I have a LINQ to SQL query which produces an object of type {System.Data.Linq.DataQuery}.
I have a foolish doubt.Generally System.Object implements Equals. When I implements IEquatable interface i
i have the following code: Private Sub TxtPStof_KeyPress(ByVal sender As System.Object, ByVal e As
i have the following code Private Sub select_color_Click(ByVal sender As System.Object, ByVal e As
Lets say we have two objects o1 & o2 defined as System.Object, in my
I have a System.Type stored in a variable. I wish to Change an object's
I have the following Powershell code: Add-Type -Assembly System.Configuration [ExeConfigurationFileMap] $configMap = New-Object ExeConfigurationFileMap

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.