Sitecore 5.1.1 API

MainUtil.IndexOf Method 

Gets the index of an object in an array.

[Visual Basic]
Public Shared Function IndexOf( _
   ByVal obj As Object, _
   ByVal objects As Object() _
) As Integer
[C#]
public static int IndexOf(
   object obj,
   object[] objects
);

Parameters

obj
An object to be found.
objects
An array of objects.

Return Value

The index of the object in the array. If not found, -1 is returned.

Remarks

This function performs a linear scan of the array to find the object.

Example

  object myObject = new object();
  object[] objects = new object[] { 0, 1, myObject, 3, 4 };
  int index = MainUtil.IndexOf(myObject, objects); // 2

See Also

MainUtil Class | Sitecore Namespace