/
aprogrammer
/
dotnet-docs
Обзор
Документация
Войти
/
aprogrammer
/
dotnet-docs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
docs/csharp/language-reference/statements/snippets/iteration-statements/ForStatement.cs
49 строк
998 B
Tom Dykstra
Update snippets for NRT (#28615)
11 мар 2022, 00:02
Не верифицирован
11 мар 2022, 00:02
aff1571
Код
Авторство
О чём код?
namespace IterationStatements; public static class ForStatement { public static void Examples() { Typical(); MultipleExpressions(); } private static void Typical() { // <TypicalExample> for (int i = 0; i < 3; i++) { Console.Write(i); } // Output: // 012 // </TypicalExample> Console.WriteLine(); } private static void MultipleExpressions() { // <MultipleExpressions> int i; int j = 3; for (i = 0, Console.WriteLine($"Start: i={i}, j={j}"); i < j; i++, j--, Console.WriteLine($"Step: i={i}, j={j}")) { //... } // Output: // Start: i=0, j=3 // Step: i=1, j=2 // Step: i=2, j=1 // </MultipleExpressions> } private static void Infinite() { // <InfiniteLoop> for ( ; ; ) { //... } // </InfiniteLoop> } }