Array

Collection elements:

Arbitrary
Iteration through collection using For each ... In ... Do operator is available to object. Array element values are retrieved during iteration.
Access to element value is possible using [...] operator. Value index (starting from 0) is passed as an argument.

Methods:

Add
Clear
Count
Delete
Find
Get
Insert
Set
UBound

Constructors:

Based on a fixed array
By number of elements

Description:

This can be used to access array elements, array methods and the wizard.

Availability:

Thin client, web-client, server, thick client, external connection, Mobile application (client), Mobile application (server).
Exchange with server is possible. Serializable. The given object may be serialized to/from XDTO. The XDTO type correspoding to this object is defined in {http://v8.1c.ru/8.1/data/core} namespace. XDTO type name: Array.

Example:

Array = New Array(4);
Message("Count: "+Array.Count());
Message("Max array index: "+Array.UBound());
Array.Delete(2); 
Message("Count after deletion: "+Array.Count());
// This element of array is of String type:
Array.Add("String added"); 
// This element of array is of Number type:
Array.Add(123.45); 
Message("Count after addition: "+Array.Count());
// Let's add an element on index greater than UBound():
Array.Insert(8,"Method added 4 new elements"); 
Message("Count after addition: "+Array.Count());
// Array can contain different data types:
Message("Types of elements: "+Chars.LF+
    "    For the 3rd element: "+TypeOf(Array[3])+Chars.LF+
    "    For the 4th element: "+TypeOf(Array[4])+Chars.LF+
    "    For the 5th element: "+TypeOf(Array[5]));

// Execution result:
// Count: 4
// Max array index: 3
// Count after deletion: 3
// Count after addition: 5
// Count after addition: 9
// Types of elements: 
//     For the 3rd element: String
//     For the 4th element: Number
//     For the 5th element: Undefined


    

1C:Enterprise Developer's Community