using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;

namespace ExemploLooping

{

    class looping

    {

        static void Main()

        {

 

            #region Do

 

            int valor = 1;

 

                    Console.WriteLine("----------DO----------");

                    do

                    {

                        Console.WriteLine(valor);

                        valor++;

                    } while (valor <= 10);

               

            #endregion

 

            #region while

 

                    Console.WriteLine("--------WHILE--------");

                    bool condicao = true;

                    valor = 50;

 

                    while (condicao)

                    {

                        if (valor == 60)

                            condicao = false;

 

                        Console.WriteLine(valor++);

                    }

            #endregion

 

            #region foreach

 

                    Console.WriteLine("--------FOREACH--------");

                    string[] deptos = { "TI", "RH", "CO", "FN" };

                   

                    //foreach (para cada) depto (departamento) in (contido em) deptos (departamentos)

                    foreach (var depto in deptos)

                    {

                        Console.WriteLine(depto);

                    }

 

 

                    Console.WriteLine("----------EXEMPLO NOTAS---------");

 

                    List<int> notas = new List<int>();

                    notas.Add(5);

                    notas.Add(6);

                    notas.Add(7);

                    notas.Add(8);

                    notas.Add(9);

 

                    foreach (var n in notas)

                    {

                        Console.WriteLine(n);

                    }

 

            #endregion

 

            #region for

 

                    Console.WriteLine("-----------FOR-----------");

 

                    for (int i = 0; i < 8; i++)

                    {

                        Console.WriteLine(i);

                    }

 

            #endregion

 

                    Console.ReadLine();

 

        }

    }

}

 

 

Até a próxima moçada! Cool