xxxxxxxxxx
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");
}
xxxxxxxxxx
/*Make sure to add
using System.Linq;
*/
string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"};
if(printer.Contains("jupiter"))
{
Process.Start("BLAH BLAH CODE TO ADD PRINTER VIA WINDOWS EXEC"");
}
xxxxxxxxxx
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");}
xxxxxxxxxx
public static bool Contains(Array a, object val)
{
return Array.IndexOf(a, val) != -1;
}
xxxxxxxxxx
//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"");
}