In X++, container is one of the primitive types, or value types. container is not a class. A container contains an ordered sequence of primitive values or other containers.
A container can be stored in the database. container is one of the column types that you can select when you use the Application Object Tree (AOT) to add a column to a table.
A container slightly resembles an array, or collections such as the List or Stack classes. However, you can never change the size or content of a container after the container is created. X++ statements that appear to modify a container are internally building a new container and copying values as necessary. Even an assignment of a container to another container variable creates a new copy of the container. All of this has performance implications.
In the X++ functions that provide access to a container (such as conPeek), the container is 1 based not 0 based. Indexing is 1 based for arrays, and for everything else in X++.
Inserts one or more elements into a container.
Syntax:
container conIns (container container,int start,anytype element,... )
Example:
static void conInsExample(Args _arg) {
container cr2 = [1, "blue", true];
container c;
int i;
;
c = conIns(c,1,"item1");
c = conIns(c,2,"item2");
for (i = 1 ; i <= conLen(c) ; i++)
{
// Prints the content of a container.
print conPeek(c, i);
}
pause;
}
A container is helpful when you must pass a variety of value types between the client and server tiers.
A container is a poor choice when you intend to repeatedly add to a list in a loop.
Comments
Post a Comment