CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Ben Reichelt's Weblog


Copying Entities in an OO Fashion



Comments

Dennis van der Stelt said:

I just learned this myself a few days ago, it's called a copy constructor. It's apparently something from C++, and in C# it doesn't exist.

Read more about it here:
http://msdn2.microsoft.com/en-us/library/ms173116.aspx

Summary:
While creating a new object, in its constructor, you pass in an object of the same type. The constructor will then copy the passed object into itself, making an exact copy.

No idea if C++ supports this by default, unfortunatly C# doesn't. But perhaps with some reflection, you can create this yourself.
# November 1, 2005 3:10 AM

breichelt said:

Thanks for the comment Dennis, that would be pretty convenient :) To support an object copy (as opposed to a database copy), we are going to use a binary serializer. We'll serialize the object, and the immediately deserialize it back to an object and then return it. This way its a brand new object (not another reference) and its an exact copy.
# November 1, 2005 9:24 AM

Christopher Steen said:

ADO.NET Provider Model Fundamentals [Via: dhayden ]
Ajax's responseXML Error [Via: ]

Anticipated...
# November 3, 2005 2:02 PM
Check out Devlicio.us!

Our Sponsors

Proudly Partnered With