HLRosenberger
asked on
Copy/Clone an object.
I'm using a third party library that has methods/objects to create PDFs and to access a page in a PDF. I want to be able to copy/clone an object that's part of this library that represents a PDF page. Just doing an assignment from one variable to another merely references the same object.
How can I do this?
How can I do this?
ASKER
.Clone does not exist. And if I try to New an instance of this object, I get: ".... Sub New( As ) is not accessible in this context because it is 'Friend'.
Is there a copy function in the library?
ASKER
no copy either. I thought maybe there was a generic .NET way to clone any object.
There is (with a caveat) - Clone - but it needs the object to implement the ICloneable interface.
https://msdn.microsoft.com/en-us/library/system.icloneable.clone(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
https://msdn.microsoft.com/en-us/library/system.icloneable.clone(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Unfortunately, it's not serializable.
ASKER
Thanks!
>>Unfortunately, it's not serializable.
So why have you accepted that as an answer in that case?
So why have you accepted that as an answer in that case?
ob2 = ob1.Clone()
if that functionality exists in the library