check array contains c# code example
Example 1: how to know if an element is in an array c#
string[] names = "John", "Susan", "Sophie";
if (names.Contains("John") //Using Contains you can know if a specific value is on an array
{
Console.WriteLine("John is a name");
}
Example 2: c# string array contains
string[] array = { "cat", "dog", "perl" };
// Use Array.Exists in different ways.
bool a = Array.Exists(array, element => element == "perl");
bool c = Array.Exists(array, element => element.StartsWith("d"));
bool d = Array.Exists(array, element => element.StartsWith("x"));