how to check if there is a match with any item in array c# code example

Example 1: how to check if a value is inside 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"");
}

Example 2: 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){  //this is way you can check wheater 
      	//do something   //index count equals to array count
	}
}