"String" Standard Type

String is the shared name used by Elements on all platforms and languages for the type used to represent character strings. In Elements, strings are immutable by-reference types (classes) that contain a sequence of Unicode Chars, accessible via a 0-based default indexer using the square brackets ([]) operator.

Strings are Objects, so string references can be nil/null, or they can contain a value of 0 or more characters. There is no maximum length for strings, except of course as constrained by memory. Since Strings are objects, the string implementation on each platform provides numerous methods and properties on the String type that can be used to work with strings.

In C#, the string keyword can also be used to refer to this type.

Literals

In all four languages, double quotes ("...") can be used to define string literals.

In Oxygene, string literals can also be defined using single quotes ('...') for strings of zero length or a length of 2 or more. (Single-quote literals with a single character are considered Char literals, but may be treated as strings depending on context.)

Type Mappings

  • On .NET, String maps to the System.String FCL class.
  • On Cocoa, String maps to the NSString class provided by the SDKs.
  • On Java, String maps to the java.lang.String JDK class.
  • On Island, String is implemented in Island RTL as RemObjects.Elements.System.String.

There is also a RemObjects.Elements.RTL.String type defined by Elements RTL for use in code that is shared across platforms. It maps to each platform's native string, but provides a more consistent API.

And the Swift Base Library defines additional extensions on the platform's String types that make it more consistent across platforms and with Swift's String type. See here for details.

Finally, Users porting Delphi code can use RemObjects.Elements.RTL.Delphi.DelphiString type defined by the Delphi RTL compatibility library. This mapping behaves more compatible with Delphi's string type, including support for mutability, and optional 1-based indexing.