Getting the index of a particular item in array

I want to retrieve the index of an array but I know only a part of the actual value in the array.

For example, I am storing an author name in the array dynamically say "author = 'xyz'".
Now I want to find the index of the array item containing it, since I don't know the value part.

How to do this?


You can use FindIndex

 var index = Array.FindIndex(myArray, row => row.Author == "xyz");

Edit: I see you have an array of string, you can use any code to match, here an example with a simple contains:

 var index = Array.FindIndex(myArray, row => row.Contains("Author='xyz'"));

Maybe you need to match using a regular expression?


     int i=  Array.IndexOf(temp1,  temp1.Where(x=>x.Contains("abc")).FirstOrDefault());

try Array.FindIndex(myArray, x => x.Contains("author"));


The previous answers will only work if you know the exact value you are searching for - the question states that only a partial value is known.

Array.FindIndex(authors, author => author.Contains("xyz"));

This will return the index of the first item containing "xyz".