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 Total Occurrence Of An Element In An Array.
Following code shows quick and easy way to get total number of occurrence of an elements 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[] array2 = Array.FindAll(array1,
element => element == 11);
Response.Write("<br/>There are <b>" + array2.Length + "</b> element in array which are equal to 11.");





