This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
2024-03-10 20:32:51 +03:00

18 lines
684 B
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Сериализация объектов
// Можно сериализовать только объекты, помеченные атрибутом [Serializable]
// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить
// один объект (один граф объектов с данным корнем)
type
[Serializable]
My = auto class
x,y: integer;
end;
const fname = 'a.dat';
begin
var m := new My(2,3);
Serialize(fname,m); // Сериализуем объект в файл
var m1 := Deserialize(fname) as My; // Десериализуем из файла
Print(m1);
end.