473,387 Members | 1,388 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,387 software developers and data experts.

determine object's collection

Hello!

This may be a silly question, but anyway:

If I have collection / list of objects:

public class MyCollection : List<MyObject>
{
}

public class MyObject
{
...
}

And then somewhere in the code I add object to the collection:
....
MyCollection col = new MyCollection()
MyObject obj = new MyObject()
col.Add(obj);

Is it possible now to determine which is obj's parent collection (sth like:
obj.?ParentCollection?) or must I manually track parent collections (e.g.
new MyObject(col) or sth like that). I know object can participate in more
than one collection at the same time (or not) so this may not be possible at
all?
Thanks in advance!

Best regards,
Jure
Nov 19 '07 #1
1 1314
On Nov 19, 11:23 am, "Jure Bogataj" <jure.boga...@mikrocop.comwrote:

<snip>
And then somewhere in the code I add object to the collection:
...
MyCollection col = new MyCollection()
MyObject obj = new MyObject()
col.Add(obj);

Is it possible now to determine which is obj's parent collection (sth like:
obj.?ParentCollection?) or must I manually track parent collections (e.g.
new MyObject(col) or sth like that). I know object can participate in more
than one collection at the same time (or not) so this may not be possible at
all?
You'd have to have specific support in MyObject for this - an object
doesn't have any inherent idea of whether it's part of another
collection or not.

Jon
Nov 19 '07 #2

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

Similar topics

4
by: Bart Plessers \(artabel\) | last post by:
Hello, I have an asp script that lists the files in a directory: CurrentPATH = "c:\temp\" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(CurrentPATH) Set...
10
by: crjunk | last post by:
I have a script that I want to run only when my input box IS NOT disabled. Can someone tell me if something is wrong with my script? Is "disabled" the correct property to use? function...
2
by: jmhmaine | last post by:
I've created a lookup class for a windows form application and I'm stuck on how on using the collection object. The process is simple, if the item is in the collection then return that object, if...
3
by: abhimanyu | last post by:
I have a method Marshal.IsComObject(...) that returns TRUE if an object is a COM object. I have an object of Excel.Worksheet that I released using Marshal.ReleaseComObject(...). I want to iterate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.