NodeCollectionIndexOf Method

Returns the zero-based index of the specified node.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public int IndexOf(
	Node node
)

Parameters

node
Type: Aspose.WordsNode
The node to locate.

Return Value

Type: Int32
The zero-based index of the node within the collection, if found; otherwise, -1.
Remarks

This method performs a linear search; therefore, the average execution time is proportional to Count.

Examples
Retrieves the index of a table in the document.
NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
int tableIndex = allTables.IndexOf(table);

Row row = table.Rows[2];
int rowIndex = table.IndexOf(row);

Cell cell = row.LastCell;
int cellIndex = row.IndexOf(cell);
See Also