This is inner for loop
I have the collection Arraylist which contain 10 lines
And i am performing some operation on that
If any line is blank it should for the next line
and i m declaring the string in which m taking that line
and if(string == "")
{break;
}
If the above condition satisfied it break the inner foreach loop and goes to outer loop
But i dont want the same
It should go for the same inner foreach loop

Show us your code please.

Instead of break use continue

foreach (string templine1 in arrline1)
{
      desti_line = "";    //this is the string which we want to write in second file
      string[] arraytempline1 = templine1.Split(','); //splitting data 
      if (templine1 == "")
      {

             break;
      }

      desti_line = arraytempline1[0] + "," + arraytempline1[1] + "," + arraytempline1      [2] + "," + arraytempline1[3] + "," + arraytempline1[4];

      float amount_from_exchange = float.Parse(arraytempline1[4]); //amount
      float transacted_amount;

      float shortage_amount;

      foreach (string templine2 in arrline2)
      {
      string temp_string = "";    //to get 1st 10 character from the line 
      string temp_acc_num = "";   //to get account number from the string
      string temp_acc_amount = "";    //to get the amount from the string
      string temp_dr_or_cr = "";      //to get Debit or Credit from the string
                        
      count++;
                        
      if (templine2 == "")
      {
                        
          break;
      }
      temp_string = templine2.Substring(0, 10);
      if (!(temp_string == "0082002100"))
      {
                        
            break;
      }
      temp_acc_num = templine2.Substring(0, 16);
      temp_acc_amount = templine2.Substring(46, 16);
      temp_dr_or_cr = templine2.Substring(63, 2);
      float amount_from_bank = float.Parse(temp_acc_amount);
      
      if (arraytempline1[2] == temp_acc_num)
      {
            shortage_amount = (amount_from_bank - amount_from_exchange);
                            
            if (shortage_amount >= 0)
            {
                shortage_amount = Math.Abs(amount_from_bank - amount_from_exchange);
                desti_line = desti_line + "," + arraytempline1[4] + "," + "0"    + ",";//shortage_amount + ",";

             }
             else
             {
                 desti_line = desti_line + "," + amount_from_bank;
                 shortage_amount = Math.Abs(amount_from_bank - amount_from_exchange);
                 desti_line = desti_line + "," + shortage_amount + "," + "S";
              }

              desti_line = desti_line + "," + arraytempline1[5] + "," + arraytempline1[6] + "," + arraytempline1[7] + "," + arraytempline1[8];

           SW1.WriteLine(desti_line);

       }   //if (arraytempline1[2] == temp_acc_num)

       }  //foreach (string templine2 in arrline2)

}//foreach (string templine1 in arrline1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.