Answers for "array contains anything c#"

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
0

c# is in array

using System.Linq; //Then you can use linq Contains() method

string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"};
if(printer.Contains("jupiter"))
{Console.WriteLine("'jupiter' is in the array");}
Posted by: Guest on January-16-2022

Code answers related to "array contains anything c#"

C# Answers by Framework

Browse Popular Code Answers by Language