Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 21st, 2004, 04:45 AM
Registered User
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default break & continue problem.

I've started learning a book for C# and I found some weak things in it. Look at the source part below.

for(int i=0;i<10;i++)
  for(int j=0;j<10;j++)
    if(j==5) break; // or continue;

Here the break statement works for J loop. How I can let it to work for the I loop. I know there is goto statement and is it possible to solve the task without using goto???


Old December 21st, 2004, 05:38 AM
Registered User
Join Date: Dec 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts

The alternative to using goto is to use a boolean variable, e.g.

bool done = false;
for(int i=0;i<10 && !done;i++)
  for(int j=0;j<10 && !done;j++)
    if(j==5) done = true;

Chris Jobson

Similar Threads
Thread Thread Starter Forum Replies Last Post
continue dayang Classic ASP Basics 1 April 29th, 2008 11:22 PM
page break on group Problem moali72 Crystal Reports 1 August 16th, 2007 04:31 AM
How to continue to next new excel worksheet christine_wmw Classic ASP Basics 0 January 24th, 2007 02:54 AM
continue topic: form lock down problem flyfish Access 6 March 30th, 2005 11:31 AM
Unable to Break at Break point Girishbk VB.NET 2002/2003 Basics 0 January 18th, 2005 08:29 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.