Check whether a value is in an array.
int[] arr = new int[] { 3, 4, 2, 1, 5, 8 }; int ky = 5; int flag = 0; foreach (int i in arr) { if (i == ky) {flag = 1; break;} }
ArrayList al = new ArrayList(); al.Add("Monday"); al.Add("Tuesday"); al.Add("Wednesday"); al.Contains("Monday");
using System.Collections.Generic; Listlst = new List { 4, 9, 18, 3 }; lst.Contains(18);
using System.Collections.Generic; Dictionaryd = new Dictionary { {"Jacobs",28},{"Mary",26} }; d.ContainsKey("Jacobs"); d.ContainsValue(28);