copy constructor

  • Thread starter Thread starter Tarscher
  • Start date Start date
T

Tarscher

Hi all,

I need to make a copy constructor for a collection class:
public class KeywordCollection : BindingList<BaseKeyword>
{}

Class KeywordCollection is nothing more than a BindingList of
BaseKeywod.

I just don't see how I can make a copyconstructor in the
KeywordCollection class.
eg: KeywordCollection keywordsNew = new KeywordCollection(keywordOld)

I hope somone can help.

Regards,
Stijn
 
Tarscher,

You have to do it yourself, like so:

public class KeywordCollection : BindingList<BaseKeyword>
{
public KeywordCollection(KeywordCollection toCopy)
{
// Copy here.
}
}

However, given that this doesn't have the same semantics in .NET as it
did in C++, you might want to look into implementing the IClonable interface
instead.
 
Tarscher said:
Hi all,

I need to make a copy constructor for a collection class:
public class KeywordCollection : BindingList<BaseKeyword>
{}

Class KeywordCollection is nothing more than a BindingList of
BaseKeywod.

I just don't see how I can make a copyconstructor in the
KeywordCollection class.
eg: KeywordCollection keywordsNew = new KeywordCollection(keywordOld)

I hope somone can help.

Regards,
Stijn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top