Returns true if the list contains the specified item.
Using:
1 2 3 |
bool result = list.Contains(3); |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
using System; using System.Collections.Generic; class Program { static void Main(string[] args) { var list = new List<int>(); list.Add(100); list.Add(200); list.Add(300); list.Add(400); list.Add(500); list.Add(600); list.Add(700); bool result = list.Contains(500); Console.WriteLine(result); Console.ReadLine(); } } |
Output:
True