CSharp examples for System:Array Search
Search for a string in an array.
// Licensed under the Apache License, Version 2.0 (the "License"); using System.Collections.Generic; using System;//from w w w. jav a 2 s. c om public class Main{ /// <summary> /// Search for a string in an array. /// </summary> /// <param name="search">Where to search.</param> /// <param name="searchFor">What we are looking for.</param> /// <returns>The index that the string occurs at.</returns> public static int FindStringInArray(String[] search, String searchFor) { for (int i = 0; i < search.Length; i++) { if (search[i].Equals(searchFor)) return i; } return -1; } }