CArray:Copy CArray:Dot

CArray:Count


The Count method returns the number of members in the CArray object.

Syntax

number = CArray:Count()

Remarks

This method returns the number of members (or values) in the CArray. This is not the same thing as the maximum index in the array. For example, if the CArray has 2 members, one at index 1 and the other at index 10000, then Count = 2.

Example

Suppose a CArray assigned to A contains 3 members as shown below:

 

A = CArray:new()

-- create a CArray

A:Set( 2, 1805 )

-- set member 2

A:Set( 50, 102 )

-- set member 50

A:Set( 120, 600.5 )

-- set member 120

Printf("N = %d", A:Count() )

-- result: N = 3

A:delete()

-- if finished with A, clean up memory

Related Topics

CArray, Exists