Question: How can I go about doing this so if the "if" statement is true, to skip the code below the foreach loop and to go on with the rest of the program

```
void()
{
    foreach()
    {
        if()
        {

        }
    }

    //code I want to skip if "if" statement is true

}

```

Answer: 
The 'break' keyword will break out of the loop.

```
foreach (someClass a in someArray) 
{
  if(a.someProperty) // bool property 
  {
    //Stuff to do if that condition is true
    doSomethingElse();
    //Calling the break keyword will stop the loop and jump immediately outside of it
    break;
  }
  //Other code to run for each iteration of the loop
}

//Here is where execution will pick up either after break is called or after the loop finishes

```
Only way I know how is a bool flag.

```
void()
{
  bool x = false;
  foreach()
  {
    if()
    {
      x = true;
      break;
    }
  }
  if(!x)
  {
    //Code to skip if "if" statement is true.
  }
}

```

Not super elegant, but easy.
Edit: beat by 12 secs :)