All three generic overloads of the Array.IndexOf method. : Array Exist Find « Data Structure « C# / CSharp Tutorial






using System;

public class Example
{
    public static void Main()
    {
        string[] dinosaurs = { "A","B","C","F","D","A","E" };

        Console.WriteLine();
        foreach(string dinosaur in dinosaurs)
        {
            Console.WriteLine(dinosaur);
        }

        Console.WriteLine("\nArray.IndexOf(dinosaurs, \"A\"): {0}", Array.IndexOf(dinosaurs, "A"));

        Console.WriteLine("\nArray.IndexOf(dinosaurs, \"A\", 3): {0}", Array.IndexOf(dinosaurs, "A", 3));

        Console.WriteLine("\nArray.IndexOf(dinosaurs, \"A\", 2, 2): {0}", Array.IndexOf(dinosaurs, "A", 2, 2));
    }
}








11.14.Array Exist Find
11.14.1.Demonstrate Predicate delegate
11.14.2.Use Array.Exists to check if a certain element exist
11.14.3.Use Array.Find to find array elements end with s
11.14.4.Use Array.FindLast to find the string element ends with s
11.14.5.Array.FindAll
11.14.6.All three generic overloads of the Array.IndexOf method.
11.14.7.Array.LastIndexOf demo
11.14.8.Using Array.TrueForAll for testing if array elements all end with string s