Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Цикл While | Цикли
Основи C#
course content

Зміст курсу

Основи C#

Основи C#

1. Початок роботи
3. Структури управління
4. Цикли
5. Масиви
6. Методи

book
Цикл While

Цикл while схожий на цикл for, однак він використовується, коли потрібно виконувати блок коду повторно на основі умови. Синтаксис циклу while простіший, ніж у циклу for:

javascript

Приклад:

cs

main

copy
12345678910111213141516
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int i = 0; while(i < 5) { Console.WriteLine(i); i++; } } } }

Although the while loop may seem very similar to the for loop at first, In more advanced levels of programming the difference becomes apparent. We might explore the usage of different kinds of loops in the Arrays section.

Note

We can write true as the condition of a while-loop to create an infinite loop. But it's not recommended to use.

cs

main

copy
123
while(true) { Console.WriteLine("Hello World"); }
question mark

How many iterations will the following loop have?

Select the correct answer

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 3
Ми дуже хвилюємося, що щось пішло не так. Що трапилося?
some-alt