0

Possible Duplicate:
Cloning objects in C#

So we have no standard definition to differ cloning from copying, let's just assume here they're the same.

Seems like it is very complicated to clone objects in C#. At least in contrast with, let's say, javascript. There are indeed many different ways to do it. And it's even argued it makes no sense copying objects.

That said, what are all our built-in options to do it? For instance, is there any non-serialized option which we wouldn't need to worry about protection?

And what are the common ways around to do it? Do we have names for them, like we have for sorting?

Community
  • 1
  • 1
cregox
  • 17,674
  • 15
  • 85
  • 116
  • now I'm confused ... isn't erverything you asked for already in the question you linked (http://stackoverflow.com/questions/78536/cloning-objects-in-c-sharp) - or do you want a 236 upvotes too? :D – Random Dev Apr 09 '12 at 20:35
  • 1
    What is being suggested in the javascript link is the same as what is being done in C# in http://stackoverflow.com/questions/78536/cloning-objects-in-c-sharp. The difference is that in JS all objects are serializable, whereas in C# they are not. C# is a sharp tool, no pun intended: http://codebetter.com/jeremymiller/2006/10/31/my-programming-manifesto/ – Chris Shain Apr 09 '12 at 20:40
  • @CarstenKönig I want someone with (way more) experience to, at least, confirm that. – cregox Apr 09 '12 at 20:43
  • I rather you guys had closed it as off-topic or ill-formatted... This is far from duplicate and I pointed many links giving many different answers to this same broader subject, but I could find none pointing why there are so many options and what are the differences. I'm not asking how to do it. – cregox Apr 09 '12 at 20:52
  • @ChrisShain thanks for the insight! I never thought of C# being sharper than javascript... Aren't you mistaking this comparison with .NET versus browser script? After all, as far as I see, javascript definition does support metaprogramming along with many other amazing features. I haven't notice what you pointed about objects being serializiable in JS versus C# and it only makes me wonder even more if C# actually is so powerful as this manifesto or you may make it looks like. Nevertheless, thanks again for the insight! :-) – cregox Apr 09 '12 at 21:03
  • @Cawas I don't want to start a flame war- javascript is a very powerful language, and with the coverage it's received lately I am sure it's use will only continue to grow. Think of it this way- I can haul stuff in a pickup truck, but I can't drive it very fast on a race track. I can take a ferrari up to 200MPH on a track, but I can't carry lumber with it. Each tool has it's uses and features, and it's your job to pick the right one for the job. – Chris Shain Apr 09 '12 at 21:07
  • @ChrisShain sorry if it looked like flaming. I do dislike C# and sometimes I let the feeling show. But, as I asked, I'd still like to hear from you if you really meant JS vs C# and then I'm missing something I should research more or if you meant .NET versus browser script, to which I couldn't agree more. NET is way more resourceful in many ways and, using the car comparison, browser script is simply a cheaper volvo which will bring you from point A to B if you don't need speed on a track nor carrying lumber. :) – cregox Apr 09 '12 at 21:13
  • @CarstenKönig I just completely edited it. Still confused? You can downvote this for all I care... Or point me to another answered actual duplicated question and delete this. I just wanted to have a list of methods we can use to copy / clone objetcs. – cregox Apr 10 '12 at 14:56

0 Answers0