BasicKnowledgeCSharp/LessonsAndTasks/Lesson 18 - Цикл for/Program.cs

26 lines
660 B
C#
Raw Normal View History

2024-10-05 09:59:53 +03:00
using System;
/*
* Цикл for
*/
class Program
{
private static int count;
static void Main()
{
//Переменная count в счетчике существует только внутри цикла
for (byte count = 0; count < 10; count++)
{
Console.WriteLine(count);
}
//Переменная count объявляется вне цикла и существует вне зависимости от положения цикла в коде
while (count < 10)
{
count++;
Console.WriteLine(count);
}
Console.ReadKey();
}
}