Total Page Preview:   000000007192

What is break and continue in C-Sharp in English and Hindi

 

Break and Continue in C-Sharp in English

In C#, break and continue are two control flow statements that are used within loops to change the normal execution flow of the program.

The break statement is used to terminate the loop and exit the loop's block of code immediately. It is typically used in conjunction with a conditional statement to stop the loop from executing under certain conditions. Here's an example of using break in a while loop:
In this example, the loop will print the value of i to the console and then increment it by 1 on each iteration. However, when i reaches a value of 5, the break statement is executed, causing the loop to terminate immediately.
The continue statement is used to skip the current iteration of the loop and move on to the next iteration. It is also typically used in conjunction with a conditional statement to skip certain iterations based on a particular condition. Here's an example of using continue in a for loop:
In this example, the loop will print the value of i to the console on each iteration, but it will only do so for odd values of i. When i is even, the continue statement is executed, causing the loop to skip that iteration and move on to the next one.
 
 
 
Break and Continue in C-Sharp in Hindi
C# mein break aur continue do control flow statements hote hain jo loops ke andar normal execution flow ko change karne ke liye istemal kiye jaate hain.
break statement ko loop ko terminate karne ke liye aur loop ke block of code se turant bahar nikalne ke liye istemal kiya jaata hai. Ye typically ek conditional statement ke saath istemal kiya jaata hai jisse loop execution ko certain conditions ke base par rukaya ja sake. Yahan ek while loop mein break ka istemal karte hue ek example diya gaya hai:
Is example mein, loop i ki value ko console par print karega aur phir har iteration mein i ki value ko 1 se increment karega. Lekin jab i ka value 5 ho jaata hai, tab break statement execute hota hai aur loop turant terminate ho jaata hai.
continue statement ko current iteration ko skip karne ke liye aur agle iteration mein move karne ke liye istemal kiya jaata hai. Ye bhi typically ek conditional statement ke saath istemal kiya jaata hai jisse kuch iterations ko skip kiya ja sake. Yahan ek for loop mein continue ka istemal karte hue ek example diya gaya hai:
Is example mein, loop i ki value ko console par print karega lekin sirf odd values ke liye. Jab i ki value even ho jaati hai, tab continue statement execute hota hai aur loop us iteration ko skip karke agle iteration mein move kar jaata hai.
 
 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: