check if item in array c# code example
Example 1: how to check if a value is inside an array c#
string[] printer = {"jupiter", "neptune", "pangea", "mercury", "sonic"};
if(printer.Contains("jupiter"))
{
Process.Start("BLAH BLAH CODE TO ADD PRINTER VIA WINDOWS EXEC"");
}
Example 2: how to check if an integer is in array c#
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"");
}
Example 3: check if that inex exisits array c#
var array=new List<int>(1,2,3);
int count=5;
for(int i=0;i<count;i++){
if(array.Count>i){
}
}