Answers for "break two for loop in unity"

C#
2

unity break 2 loops

using System;

class Example
{
    static void Main()
    {    
        for (int i = 1; i <= 7; i++)
        {
            for (int j = 1; j <= 7; j++)
            {
                int product = i * j;

                if (product >= 20)
                {
                    goto LoopEnd; //Stops all the loops to go to "LoopEnd:" on 23th line
                }

                Console.Write("{0}t", product);
            }
            Console.Write("n");
        }

    LoopEnd:
        Console.WriteLine("nFinished with calculations.");
    }
}
Posted by: Guest on February-06-2021

C# Answers by Framework

Browse Popular Code Answers by Language