For Loop Array, skip 1 value

Hi guys,

I got a question about an array in a for loop here is my code:

		for (int i = 0; i < theScrews.Length; i++) {
						theScrews *.renderer.material.color = Color.black;*
  •  }*
    

As you can see there is nothing wrong with it.
But my question is, is it possible to skip for example theScrews[2]. So it wont change the color.
Here is the “psuedo code”

  •  for (int i = 0; i < theScrews.Length; i++) {*
    

_ theScrews .renderer.material.color = Color.black;_
except for theScrews[2]
//theScrews[2] doesn’t change to the color black
* }*

Make it skip the number 2.

for(int i = 0 ; i < whatever ; i++)
{
   if(i == 2) continue ;
   //do the other stuff here
}

The easiest way would be to add an if statement, like this:

for (int i = 0; i < theScrews.Length; i++) {
             if(i != 2) // 
                 theScrews *.renderer.material.color = Color.black;*

}
You could also check against multiple values (for example, if you’d like to omit objects at index 2 and 5):
List exceptions = new List();
exceptions.Add(2);
exceptions.Add(5);

for (int i = 0; i < theScrews.Length; i++) {
if(!exceptions.Contains(i))
theScrews .renderer.material.color = Color.black;
}