Looping Introduction

October20, 2017
by admin

Sometimes programmer has to write the code to repeat the same statement or statements for certain number of times or until any condition satisfies.

Here is the role of looping statements. Instead of writing the code or copying the code and paste it for many times repeatedly, you can use loop statements in C# which help you write code statements once and then execute them repeatedly as per your wish or program requirement.

Three main loop statements are available in C# as follows:

1. while loop

2. do while loop

3. for loop

The while loop and do while loops are somewhat similar but with one difference. The ‘for’ loop is completely different from these both and is helpful in some situations.

We are going to learn these three loop statements with some simple easy to understand code examples. We will discuss the control flow of each one and when to use each one in coding.

C# Fundamentals