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 Compare Elements In Array Using FindAll() Method
Following code shows an array. Further it also show you the best way to compare elements with a value. Following code will print total elements which are less than equal to 11.
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 less than 11.");





