int array contains c# code example
Example 1: c# check if array contains value
public static bool Contains(Array a, object val)
{
return Array.IndexOf(a, val) != -1;
}
Example 2: how to check if an integer is in array c#
//Add necessary namespace
using System.Linq;
//Example
string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"};
//using .Contains() method
if(printer.Contains("jupiter"))
{
Process.Start("BLAH BLAH CODE TO ADD PRINTER VIA WINDOWS EXEC"");
}