Any difference?

 

Would there be any difference in the result between the following two pieces of code?

First one:

if (FirstCurr == "GBP" && SecondCurr == "AUD") Pair = "GBPAUD";
   {
      if ((GBPbefore > AUDbefore) && (GBPafter < AUDafter)) 
      SellArray[3] = true;
      if ((GBPbefore < AUDbefore) && (GBPafter > AUDafter))
      BuyArray[3] = true;
   }


and

if (FirstCurr == "GBP" && SecondCurr == "AUD") 
    {
      Pair = "GBPAUD";
      if ((GBPbefore > AUDbefore) && (GBPafter < AUDafter)) 
      SellArray[3] = true;
      if ((GBPbefore < AUDbefore) && (GBPafter > AUDafter))
      BuyArray[3] = true;
   }
 
ernest02:

Would there be any difference in the result between the following two pieces of code?

First one:


and

Of course. In the first case the block under {} is always executed. In the second case not.
 
ernest02:

Would there be any difference in the result between the following two pieces of code?

First one:

if (FirstCurr == "GBP" && SecondCurr == "AUD") Pair = "GBPAUD";
   {
      if ((GBPbefore > AUDbefore) && (GBPafter < AUDafter)) 
      SellArray[3] = true;
      if ((GBPbefore < AUDbefore) && (GBPafter > AUDafter))
      BuyArray[3] = true;
   }

and

if (FirstCurr == "GBP" && SecondCurr == "AUD") 
    {
      Pair = "GBPAUD";
      if ((GBPbefore > AUDbefore) && (GBPafter < AUDafter)) 
      SellArray[3] = true;
      if ((GBPbefore < AUDbefore) && (GBPafter > AUDafter))
      BuyArray[3] = true;
   }

The green highlighted code will execute only if the IF statement (in blue) is true, and the red highlighted code will execute regardless whether the IF statement (in blue) is true. In other words, the red highlighted code is not logically connected to the conditional IF statement highlighted in blue and therefore will always be executed.
 

Thanks guys! This helped me a lot and saved me many hours of finding the mistake!

Ernest.