Official Content

Returns the index associated to an SDT item in an SDT collection.

Syntax

&VarBasedOnSDTCollection.IndexOf(&VarBasedOnSDTItem)

Where:

&VarBasedOnSDTCollection
     It must be a variable based on an SDT collection (or a variable based on a simple SDT and defined as a collection).

&VarBasedOnSDTItem
     Variable based on an SDT item.

Scope

Generators:  .NET, .NET Framework, Java, Ruby (up to GeneXus X Evolution 3)

Description

It returns the index (a numeric value) associated with the Item parameter element of an SDT collection.

Samples

In general, the IndexOf method of an SDT Collection is used in conjunction with the Remove method. Once you have the desired index (position in the SDT), you can use the associated Remove method.

&index = &sdtCollection.IndexOf(&sdtCollection.CurrentItem)
&sdtCollection.Remove(&index)

Considerations

This method works with the elements' references and not with their contents. This implies that if a variable with a list of SDT is received as a parameter and a temporary variable is loaded with an item content, IndexOf will return 0 (empty) since this reference is not within the list. It can be useful only in the moment the list is loaded.

See Also

Structured Data Type methods


Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant