Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,926 questions

51,859 answers

573 users

How to continue outer loop in C#

2 Answers

0 votes
using System;

class Program
{
    static void Main()
    {
        for (int outer = 0; outer < 4; outer++) {
            for (int inner = 0; inner < 3; inner++) {
                if (inner == 2) {
                    goto ContinueOuter; // Jump to the label to continue the outer loop
                }
                Console.WriteLine($"Outer: {outer}, Inner: {inner}");
            }

        ContinueOuter:
            // Label to jump to
            Console.WriteLine($"continue_outer: {outer}");
        }
    }
}


/*
run:

Outer: 0, Inner: 0
Outer: 0, Inner: 1
continue_outer: 0
Outer: 1, Inner: 0
Outer: 1, Inner: 1
continue_outer: 1
Outer: 2, Inner: 0
Outer: 2, Inner: 1
continue_outer: 2
Outer: 3, Inner: 0
Outer: 3, Inner: 1
continue_outer: 3

*/

 



answered Apr 24, 2025 by avibootz
0 votes
using System;

public class Program
{
    public static void Main(string[] args)
    {
        int[] arr1 = {4, 5, 1, 1, 6, 7, 0, 1, 1, 1, 8};
        int[] arr2 = {9, 1, 2};

        int nval2 = 0;
        foreach (int val1 in arr1) {
            foreach (int val2 in arr2) {
                nval2 = val2;
                if (val2 == val1) {
                    break;
                }
            }
            if (nval2 == val1) {
                continue;
            }
                
            Console.Write(val1 + " ");
        }
    }
}


/*
run:

4 5 6 7 0 8 

*/

 



answered Apr 24, 2025 by avibootz

Related questions

3 answers 80 views
80 views asked Apr 28, 2025 by avibootz
1 answer 64 views
1 answer 83 views
3 answers 144 views
2 answers 96 views
1 answer 117 views
117 views asked Apr 24, 2025 by avibootz
...