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

# TCustomVariantType.Cast

Cast a custom variant to another type

## Declaration

Source position: variants.pp line 200

`public procedure TCustomVariantType.Cast(`
`var Dest: tvardata;`
`const Source: tvardata`
`); virtual;`

## Arguments

`Dest` |  | Custom variant to copy value to
`Source` |  | Variant to copy value from

## Description

Cast is called when a variant value Source is cast to a custom variant Dest. Descendents must override this method to provide the desired conversion behaviour.

The TCustomVariantType implementation of Cast calls CastTo on the source variant with as destination type the custom variant type.

## Errors

If the variant type cannot be cast, an exception is raised.

## See also

TCustomVariantType.CastTo |  | Cast a custom variant to another type
TCustomVariantType.CastToOle |  | Cast variant value to OLE value