Array.IndexOf(), Array.LastIndexOf() (C#)
<%@Page Language="c#" %>
<script runat="server" Language="c#">
void Page_Load()
{
int intCounter = -1;
string[] AnimalArray = new string[5]
{ "Dog", "Cat", "Elephant", "Lion", "Cat"};
do
{
intCounter = Array.IndexOf(AnimalArray, "Cat", intCounter+1);
MyText.InnerHtml += "AnimalArray[" + intCounter + "]<br/>";
} while (intCounter != Array.LastIndexOf(AnimalArray, "Cat"));
}
</script>
<html>
The string "Cat" occurs in the following elements:
<br/>
<div id="MyText" runat="server" />
</html>
Related examples in the same category