Benoit
0
Q:

how to know if an element is in an array c#

/*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"");
}
7
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");
    }
1

New to Communities?

Join the community