Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 82.4k

how to search identical element in an array?

Dec 8 2021 11:35 AM

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)