This method is use to explicitly convert a
value of one data type to another or invoke implicit conversion from one type to
another.
Examples
The Example below
demonstrates how to wrap tthrough casting a derived interface type to the base
type.
Delphi
varobaseExc:_Exception;argumentExc:_ArgumentException;begin// Create a new derived type.
argumentExc:=CoArgumentException.CreateInstance; // Conversion to the base type
obaseExc:=CoException.Wrap(argumentExc);// Explicit conversion is required to cast back
// to derived type. This is done using the same method
argumentExc:=CoArgumentException.Wrap(obaseExc)end.
The Example below
demonstrates how to
explicitly convert an integer value to a decimal interface type.
Delphi
varoDecimal:_Decimal;oInt32:Integer;begin// NB: Create instance of Console Interface Type
// To convert integer value to decimal object, you can use the wrap method of the
// _Decimal interface.
oInt32:=45;oDecimal:=CoDecimal.Wrap(oInt32);Console.WriteLine_15('Convert Integer value ''45'' to Decimal value using the Wrap method, '+'the Decimal value is {0}.',oDecimal);end.