I have a class object System.Windows.Documents.Run, I need it to copy. There are options other than manually?
Serialization is a common way to clone an object (if you don't want to code it manually) - is is serializable? (or: could it be?)
This has the advantage of being a deep clone and maintenance-free, but is slower ( how much slower depends on the serializer chosen).
Note: if you choose to use BinaryFormatter
, make sure you mark any events as [field:NonSerialized]
. BinaryFormatter
isn't my preferred serializer, but it is acceptable for in-memory cloning purposes (and is simple to get working - just mark your types as [Serializable]
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.