Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a code inside the c# page.
i want to jump if loop to while loop like this....

while (-------)
   {
       for (-----)
       {
           if (------)
           {
               --------
               goto outer;
           }
        }
    outer:
        -------
        ---------
        --------
   }


but its not possible due to jump inside the loop.
so have u any solution about it?
Posted

A break statement (instead of the goto) would cause the effect you need.
 
Share this answer
 
Comments
jkpatelce 14-Sep-12 11:27am    
thnx.... bro
hii,

hey dude nothing to do other than your code
see below sample code

C#
int i=0;
            while (i < 70)
            {
                for (int j = 0; j < 100; j++)
                {
                    if ( j == 87)
                    {
                        goto outer;
                        Console.WriteLine("in loop" + j.ToString());
                        Console.WriteLine("in loop" + (j+1).ToString());
                    }
                }
            outer:
                Console.WriteLine("out loop" + i.ToString());
                Console.WriteLine("out loop" + (i + 1).ToString());
                i++;
            }
            Console.ReadKey();



this will always print

C#
Console.WriteLine(&quot;out loop&quot; + i.ToString());
                Console.WriteLine(&quot;out loop&quot; + (i + 1).ToString())



hope you will get what you want.
have happy coding
 
Share this answer
 
Comments
jkpatelce 14-Sep-12 11:27am    
thnx....man

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900