C# Extension Method: Array - IndexOf

CSharp · Console

/Program.cs

// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002173/array-indexof

// @nuget: Z.ExtensionMethods

using System;

public class Program
{
	public static void Main()
	{
       String[] strings = { "the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog", "in", "the", "barn" };
       
       String searchString = "jumps";

		// C# Extension Method: Array - IndexOf
        int index = strings.IndexOf(searchString);

        Console.WriteLine("The first occurrence of \"{0}\" is at index {1}.",
                         searchString, index);
	}
}
;