Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8722849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:29:58+00:00 2026-06-13T07:29:58+00:00

foreach (String host in hostArray) { string s1 = hostArray[t]; string s2 = branchArray[t];

  • 0
foreach (String host   in hostArray)
{
    string s1 = hostArray[t];
    string s2 = branchArray[t];
    string con_msg;
    t=t+1;
    TcpClient socketForServer;
    try
    {
        socketForServer = new TcpClient(s1, 10);
        con_msg="Connected";
    }
    catch
    {
        ListViewItem item = new ListViewItem();
        item.BackColor = Color.LightGreen;
        item.Text = (s2);
        item.SubItems.Add(s1);
        item.SubItems.Add("Not found");
        listView1.Items.Add(item);
        con_msg = "Not connected";
        // I want to exit this round in here and and start next round  how to do it 
    }

    NetworkStream networkStream = socketForServer.GetStream();
    System.IO.StreamReader streamReader =  new System.IO.StreamReader(networkStream);
    System.IO.StreamWriter streamWriter =new System.IO.StreamWriter(networkStream);
    //code
}

I want to exit current round in catch and start next round. how to do it. I don’t want to exit foreach loop , i just want to exit from current round and start next round

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:29:58+00:00Added an answer on June 13, 2026 at 7:29 am
    foreach (var item in Items)
    {           
      try
      {
        //Exception
      }
      catch (Exception)
      {
        continue;//Will move to next item of "Items" of FOREACH LOOP
      }
    
      int a = 1 + 1;//If exception gets this line will not execute
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this code: List<string> things = new List<string>(); foreach (string thing in things) {
here's my code: XmlDocument doc = new XmlDocument(); foreach (string c in colorList) {
foreach (string sn in MACOrSerial.Split(',')) { MACOrSerial = sn.Trim(); } MACORSerial contains a string
Suppose I have the following code: foreach(string str in someObj.GetMyStrings()) { // do some
So i have this code: foreach (string xmlfilelisted in xmlFileList) { resultXml.Root.Add(XDocument.Load(xmlfilelisted).Root.Elements()); resultXml.Save(filepath); }
[AcceptVerbs(HttpVerbs.Post)] public ActionResult Upload(Photo photo) { foreach (string file in Request.Files) { var path
I am adding checkboxes dynamically to silverlight stackpanel object as follows: foreach (String userName
I see some people write: //wordList is List<string> wordList.ForEach(delegate(string word){ Console.WriteLine(word);}); instead of: foreach(string
Is it possible in C# to something like the following foreach (ref string var
I want to run SearchResultByOrderNumber(string orderNumber) method in Foreach with multithreading. There are ten

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.