Boxing Primitive Types

Primitive types can be boxed into object wrappers to convert them into numbers This is very handy in a number of cases, including the possibility of using object container classes to hold primitive types along with objects, the notion that an object reference can host anything (including a primitive value), the and ability to apply some of the predefined methods of the base Object class (like the ToString method) to any value Of course, one could argue that a pure object-oriented language...

Type Casts On the Safe Side

The Delphi language tends to force the developers to use the type system in an appropriate way. By treating the base data types as different entities (if you compare it, for example, with the C language) programs tends to be better written and more readable. For example, an enumeration is not the same as an integer, an integer is not type-compatible with a character, and so on. Still the Delphi language allows you to code a direct type cast, imposing your own rule on top of what the compiler...

Delphi New Predefined Records

The presence of a sophisticated record type definition and of the operators overloading has led Borland to change a lot of predefined Delphi types turning them into records. Notable examples are the types variant, datetime, and currency. Variants in particular represent another data type not part of the CLR foundations that Borland has been able to redefine on top of the available CLR features without affecting the syntax and the semantic of the existing code. The implementation of variants on...

Strings

Strings are just strings and considering that Delphi long strings are allocated on the heap, reference counted and use the copy-on-write technique, .NET strings will be quite familiar. There are a few differences, though. The first is that strings on .NET use UTF16 Unicode characters, that is each character is represented with 16 bits of data 2 bytes . This is transparent, as when you index into a string looking for a given character, the index will be that of the character, not that of the...

Primitive Types

The .NET CLR defines quite a few primitive types, which are not natively mapped to objects but a direct representation not predefined, as it can change with the target CPU and operating system version, for example on a 32biit or 64bit CPU . The CLR primitive types are mapped to corresponding Delphi types, as the following table highlights. Borland.Delphi.System.Currency a record based on Decimal What you can notice is that not all Delphi types have a CLR equivalent. You are recommended not to...