System.Rtti.TValue.Cast

De RAD Studio API Documentation
Aller à : navigation, rechercher

Delphi

function Cast<T>(const EmptyAsAnyType: Boolean = True): TValue; overload;
function Cast(ATypeInfo: PTypeInfo;  const EmptyAsAnyType: Boolean = True): TValue; overload;

C++

TValue __fastcall TValue::Cast(const bool EmptyAsAnyType)/* overload */
TValue __fastcall Cast(System::Typinfo::PTypeInfo ATypeInfo, const bool EmptyAsAnyType = true)/* overload */;

Propriétés

Type Visibilité  Source Unité  Parent
function public
System.Rtti.pas
SystemRtti.h
System.Rtti TValue

Description

Transtype la valeur actuellement stockée en un autre type.

Appelez Cast pour convertir la valeur stockée en un autre type. Cast requiert le paramètre ATypeInfo, qui représente l'information de type du type de destination. Cast renvoie un enregistrement TValue nouveau contenant la valeur convertie si la conversion a réussi ; sinon, une exception est déclenchée.

Le variant générique de cette méthode ne requièrt pas de paramètres, car elle obtient les informations PTypeInfo de manière interne.

Voir aussi