The loop constructs is used to execute a block of code until the condition is satisfied. Loop constructs in C#, restrict the programmer for writing same line multiple times which is repetitive in nature.
2. The loop constructs is used to execute a block of code until the condition is
satisfied. Loop constructs in C#, restrict the programmer for writing same line
multiple times which is repetitive in nature. eg: writing "ProgrammingsGuru"
five times by Console.WriteLine, here we can use looping construct for
display this.
3. While Loop : It's execute a block of statements for a definite number of
times, depending on the condition. While loop checks the condition before
executing the block of statements.
Syntax:
initialization
while(condition)
{
yourstatements;
increment/decrement;
}
7. Foreach : Foreach loop is a different kind of looping constructs in C#. It
takes value one by one and then processes them.
Syntax :
foreach (string name in arr)
{
yourstatements;
}