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

Snippets has posted 5883 posts at DZone. View Full User Profile

Quick Way To Check Existence Of An Elements In Array

01.30.2012
| 3844 views |
  • submit to reddit
        Check whether an element exist in array or not.

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};
 
Response.Write("<br/><br/><li>Check whether element 209 Exists in Array.</li>");
            bool isExist = Array.Exists(array1,
element => element == 209);