Answers for "how to check if exist in array c#"

C#
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");
    }
Posted by: Guest on October-25-2020
0

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 "how to check if exist in array c#"

C# Answers by Framework

Browse Popular Code Answers by Language