Answers for "c sharp how to see if array contains string"

C#
3

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"));
Posted by: Guest on March-25-2021
1

c# check if array contains value

public static bool Contains(Array a, object val)
    {
        return Array.IndexOf(a, val) != -1;
    }
Posted by: Guest on November-10-2020

Code answers related to "c sharp how to see if array contains string"

C# Answers by Framework

Browse Popular Code Answers by Language