[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Classes' (#rtl)

TPersistent.AssignTo

Generic assignment function.

Declaration

Source position: classesh.inc line 384

protected procedure TPersistent.AssignTo(

  Dest: TPersistent

); virtual;

Description

AssignTo is the generic function to assign the class' contents to another class. This method must be overridden by descendent classes to actually assign the content of the source instance to the destination instance.

The TPersistent implementation of Assignto raises an EConvertError exception. This is done for the following reason: If the source class doesn't know how to assign itself to the destination class (using AssignTo), the destination class may know how get the data from the source class (using Assign). If all descendent methods are implemented correctly, then if neither of the two classes knows how to assign their contents to each other, execution will end up at TPersistent.Assign, which will simply execute

Dest.AssignTo(Self);

If neither of the classes knows how to assign to/from each other, then execution will end up at the TPersistent implementation of AssignTo, and an exception will be raised.

See also

Assign

  

Assign the contents of one class to another.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.