Check if a string array contains a value in CSharp
Description
The following code shows how to check if a string array contains a value.
Example
using System;//from w w w . j ava 2 s . c o m
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
string[] presidents = {"HTML", "HTML5", "CSS", "CSS3", "Java", "java2s.com"};
bool contains = presidents.Contains("H");
Console.WriteLine(contains);
}
}
The code above generates the following result.