Task[edit]
Find the index of a string (needle) in an indexable, ordered collection of strings (haystack).

Raise an exception if the needle is missing.

If there is more than one occurrence then return the smallest index to the needle.

Extra credit
Return the largest index to a needle that has multiple occurrences in the haystack.

See also
 Search a list of records

using System;
using System.Collections.Generic;
 
class Program {
    static void Main(string[] args) {
        List<string> haystack = new List<string>() { "Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Bozo" };
 
        foreach (string needle in new string[] { "Washington", "Bush" }) {
            int index = haystack.IndexOf(needle);
 
            if (index < 0) Console.WriteLine("{0} is not in haystack",needle);                
            else Console.WriteLine("{0} {1}",index,needle);
        }
    }
}