i wonder fastest way shallow copying in c#? know there 2 ways shallow copy:
- memberwiseclone
- copy each field 1 one (manual)
i found (2) faster (1). i'm wondering if there's way shallow copying?
this complex subject lots of possible solutions , many pros , cons each. there wonderful article here outlines several different ways of making copy in c#. summarize:
clone manually
tedious, high level of control.clone memberwiseclone
creates shallow copy, i.e. reference-type fields original object , clone refer same object.clone reflection
shallow copy default, can re-written deep copy. advantage: automated. disadvantage: reflection slow.clone serialization
easy, automated. give control , serialization slowest of all.clone il, clone extension methods
more advanced solutions, not common.
Comments
Post a Comment