2
Answers

how to search identical element in an array?

Hi

I want to het the position of the two "Ford" in the array. The first is not a problem, but how to get the next?

Thanks

   string[] cars = { "Volvo", "BMW", "Ford", "Mazda","Ford" };
        int p = Array.IndexOf(cars, "Ford");
        Console.WriteLine("Ford is at position {0} ", p + 1);
        //p = Array.IndexOf(cars, "Ford", 1);
        //Console.WriteLine("Ford is on position {0} ", p + 1);

Answers (2)