DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Quick Way To Get First Occurence Of An Elements In Array Using FindIndex Method
Following code will find first occurrence of an element in array
int[] array1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 12, 13, 14, 12, 13, 14, 12, 13, 14, 12, 13, 14, 12, 13, 14 ,12,14,11,2,11,31};
int indexOf11 = Array.FindIndex(array1,
element => element == 11);
Response.Write("<br/>Index of Element 11 is <b>" + indexOf11 + "</b> in array.");





