Here's a custom function that returns the first array item that has duplicates in an array object. //in your main function #region testdata //string[] split_cities = new string[] { "perth", "sydney", "perth" }; //string[] split_cities = new string[] { "perth", "sydney", "gold" }; //string[] split_cities = new string[] { "nsw", "sydney", "sydney" }; //string[] split_cities = new string[] { "nsw", "nsw", "sydney" }; //string[] split_cities = new string[] { "nsw", "coast", "sydney", "nsw" }; //string[] split_cities = new string[] { "auck", "coast", "nsw", "nsw" }; string [] split_cities = new string [] { "auck" , "nsw" , "nsw" , "coasts" }; //string[] split_cities = new string[] { "auck", "coast&