473,386 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to get the class instance which creat another.

How to get the class instance which creat another. For example:

public class A
{
private B bb;
public void CreatMethod()
{
bb = new B();
}
}

My question is how can I get the instance of class A through bb.
Thanks!
Nov 17 '05 #1
2 1171
One way is for A to pass a reference to itself to B's constructor:

public class A
{
private B bb;
public void CreatMethod()
{
bb = new B(this);
}
}
public class B
{
public A _parent;

public void B( A parent )
{
_parent = parent;
}
}

Regards,

William D. Bartholomew
http://blog.bartholomew.id.au

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
Thank you William for your help. But as I know that's not a good way. I hear
from my friend that .Net has some method for get the create instance through
the object which created by it. Who know that method. Please give a
notification. Thanks!
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris | last post by:
Hi, I don't get the difference between a struct and a class ! ok, I know that a struct is a value type, the other a reference type, I understand the technical differences between both, but...
3
by: ironpythonster | last post by:
Hi everyone,there is a simply question puzzle me: Under the CPP,where can use the char* to creat a string class for use,but under the .NET Framework? How to use C# to creat a string class as the...
11
by: TinaJones095 | last post by:
Hello I am going to give a program that I have done, but I have to modifiy it, but I need help okay can you help ? Here the program I need help to straighten up below: the Java error is right at...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.