Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > C# (си шарп)
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 26.11.2016, 18:09   #1
BadCats
Пользователь
 
Аватар для BadCats
 
Регистрация: 31.01.2016
Сообщений: 67
Сообщение Дамп памяти И MembeerwiseClone()?

Объясните Человеческим языком что такое Дамп памяти? И каким образом он используется при вызове MembeerwiseClone() ?
Всем привет, просто я прохожу онлайн курс, в одном из уроков которого автор говорит, что при использовании MembeerwiseClone() в отличии от использовании конструктора - цитирую "по сути "забегает" в область памяти, хватает ее дамп и простым копированием - копирует его в другую область,перезаписывает адреса и никаких конструкторов MembeerwiseClone() не вызывает" . А и еще один вопрос: о перезаписи каких адресов в скопированном дампе памяти говорит автор ?
BadCats вне форума Ответить с цитированием
Старый 26.11.2016, 18:19   #2
Alex11223
Старожил
 
Аватар для Alex11223
 
Регистрация: 12.01.2011
Сообщений: 19,500
По умолчанию

Цитата:
Сообщение от BadCats Посмотреть сообщение
что такое Дамп памяти?
Зависит от контекста.

А про MemberwiseClone не проще документацию почитать?

https://msdn.microsoft.com/en-us/lib...wiseclone.aspx

Цитата:
The MemberwiseClone method creates a shallow copy by creating a new object, and then copying the nonstatic fields of the current object to the new object. If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.

For example, consider an object called X that references objects A and B. Object B, in turn, references object C. A shallow copy of X creates new object X2 that also references objects A and B. In contrast, a deep copy of X creates a new object X2 that references the new objects A2 and B2, which are copies of A and B. B2, in turn, references the new object C2, which is a copy of C. The example illustrates the difference between a shallow and a deep copy operation.

There are numerous ways to implement a deep copy operation if the shallow copy operation performed by the MemberwiseClone method does not meet your needs. These include the following:

- Call a class constructor of the object to be copied to create a second object with property values taken from the first object. This assumes that the values of an object are entirely defined by its class constructor.

- Call the MemberwiseClone method to create a shallow copy of an object, and then assign new objects whose values are the same as the original object to any properties or fields whose values are reference types. The DeepCopy method in the example illustrates this approach.

- Serialize the object to be deep copied, and then restore the serialized data to a different object variable.

- Use reflection with recursion to perform the deep copy operation.
Ушел с форума, https://www.programmersforum.rocks, alex.pantec@gmail.com, https://github.com/AlexP11223
ЛС отключены Аларом.
Alex11223 вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Дамп памяти анже Помощь студентам 2 13.05.2015 10:09
Как пропарсить дамп памяти процесса? siviv Общие вопросы Delphi 17 12.10.2014 21:17
дамп памяти? TotKtoNado Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM 18 11.11.2011 21:03
Дамп памяти чужого процесса Crystallon Общие вопросы Delphi 68 01.09.2011 00:50
дамп памяти ymanety Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM 0 22.12.2010 17:36