Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# difference between break and continue

break: 
1. It is used to terminate the enclosing loop like while, do-while, for, 
or switch statement where it is declared.
2. It resumes control over the program until the end of the loop.
3. It also helps with the flow of control outside the loop.
4. It is used with ‘switch’ and ‘label’ since it is compatible.
  
continue:
1. It helps skip the remaining part of the loop.
2. It continues to execute the next iteration.
3. It causes early execution of the next iteration of the enclosing loop.
4. It can’t be used with ‘switch’ and ‘label’ since it is not compatible.
  
class Program
    {
        static void Main(string[] args)
        {
            int i;
            for (i = 0; i <= 10; i++)
            {
                if (i == 5)
                  continue;
                if (i == 8)
                  break;
                Console.WriteLine("value is"  +i);
            }
            Console.ReadLine();
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to destroy object in unity c# 
Csharp :: unity scriptable object 
Csharp :: system command in c# 
Csharp :: check animation end unity 
Csharp :: Schema::defultString larvel 
Csharp :: c# insert into database 
Csharp :: unity remove gameobject 
Csharp :: c# main method 
Csharp :: c# ip address translate localhost 
Csharp :: get value from web.config c# 
Csharp :: how to make rb.addforce 2d 
Csharp :: string to date vb 
Csharp :: alert message in c# windows application 
Csharp :: unity projectile spread 
Csharp :: Add float value to ui text in unity 
Csharp :: c# connection string 
Csharp :: unity c# timer 
Csharp :: c# system.drawing.color to system.windows.media.color 
Csharp :: jitter on collision for 2 rigid bodies 
Csharp :: xamarin picker item 
Csharp :: text not centered winforms button 
Csharp :: how to write switch statement unity 
Csharp :: Arrange array element in right and left order starting from least element 
Csharp :: Codewars Multiply 
Csharp :: unity pause scene 
Csharp :: game object find 
Csharp :: c# how to exit program 
Csharp :: change array size in unity 
Csharp :: unity access phone camera 
Csharp :: c# keep console open 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =