PC Review


Reply
Thread Tools Rate Thread

Cloning an object which contains a collection

 
 
deltaquattro
Guest
Posts: n/a
 
      17th Mar 2010
Hi,

another OOP question: I'm implementing a Class which contains a
Collection property. Until now, all properties in my objects would be
either scalars or arrays of a basic type (Long, Double, etc.). But
now, one of them is a Collection. The Collection is used to store
String variables: I'm not trying to do something as perversed as deep
cloning of an object which contains another object which contains
other objects, etc, etc, How can I implement the Clone method, to
correctly clone also the Collection property? I guess I'll have to do
something like:

' Class1

Public Function Clone() As Class1
Dim Str As String
Set Clone = New Class1
'code to copy "regular" properties
For Each Str in Me.ErrString 'ErrString is the Collection inside
Class1
Clone.ErrString.Add Str
Next
End Sub

Is this the best way? Thnx,

Best Regards

deltaquattro
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding class object to collection repeats same object through collection? Erazmus Microsoft Excel Programming 2 17th Sep 2007 04:35 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
collection object not showing properties of stored object? =?Utf-8?B?UmljaA==?= Microsoft VB .NET 5 8th Nov 2006 05:51 PM
To store object and access by key(string), what collection object is the best performance one? Thanks. david Microsoft C# .NET 1 12th Dec 2003 03:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:32 PM.