By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,626 Members | 1,750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,626 IT Pros & Developers. It's quick & easy.

Collection of Collection Clone

P: n/a

I have a Collection called Grooming. Each object in this collection contains
the property GroomingServices of type Collection.
I also have a Clone of this Groomings collection called GroomingsInit. The
sub-collection GroomingServices has also been cloned.

My question is:
Can I simply set Groomings = GroomingsInit? Will the sub-collection
also be set to that of the GroomingInit?

Example:
Below is a method in my clsGroomings class object.

Public Function Clone() as Object Implements ICloneable.Clone
dim GroomingsClone as new clsGroomings
dim GroomingClone as clsGrooming

For each objGrooming as clsGrooming in Me
GroomingClone = new clsGrooming
GroomingClone.BeginTime = objGrooming.BeginTime
GroomingClone.EndTime = objGrooming.EndTime
GroomingClone.objGroomingServices = objGroomingServices.Clone
GroomingsClone.Add(GroomingClone)
Next

Return GroomingsClone
End Sub

NOTE: The objGroomingServices has it's own Clone method similar to the one
above.

Thankyou for any input.

Jeff
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jeff,

Does this sample make it clear for you?

\\\
Dim a As New ArrayList
Dim b As ArrayList
b = a
If a Is b Then _
MessageBox.Show("a and b references the same arraylist")
b = DirectCast(a.Clone, ArrayList)
if Not a Is b Then _
MessageBox.Show("we are not the same")
a.Add("Jeff")
b.Add("Cor")
MessageBox.Show("Hello " & a(0).ToString & _
" and " & b(0).ToString)
///

I hope this helps?

Cor

"Jeff Haumesser" <ha*******@karpel.com>
I have a Collection called Grooming. Each object in this collection contains
the property GroomingServices of type Collection.
I also have a Clone of this Groomings collection called GroomingsInit.
The sub-collection GroomingServices has also been cloned.

My question is:
Can I simply set Groomings = GroomingsInit? Will the sub-collection
also be set to that of the GroomingInit?

Example:
Below is a method in my clsGroomings class object.

Public Function Clone() as Object Implements ICloneable.Clone
dim GroomingsClone as new clsGroomings
dim GroomingClone as clsGrooming

For each objGrooming as clsGrooming in Me
GroomingClone = new clsGrooming
GroomingClone.BeginTime = objGrooming.BeginTime
GroomingClone.EndTime = objGrooming.EndTime
GroomingClone.objGroomingServices = objGroomingServices.Clone
GroomingsClone.Add(GroomingClone)
Next

Return GroomingsClone
End Sub

NOTE: The objGroomingServices has it's own Clone method similar to the
one above.

Thankyou for any input.

Jeff

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.