How can I show the values that are stored in the for cycle from C # console [closed]

-2

Enter 5 numbers and show on screen

        int n=1;

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

            {
                Console.WriteLine("Dame un numero");
                n = Convert.ToInt16(Console.ReadLine());

        }

        Console.ReadKey();
    
asked by Cesarhr 07.11.2018 в 19:31
source

1 answer

-2

For your solution I advise you to load the values in an Array to go through it later, this will allow you to print them all together and manipulate them later if necessary, then I will provide you with a solution

 ArrayList numeros = new ArrayList();

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

        {
            Console.WriteLine("Dame un numero");
            numeros.Add(Convert.ToInt16(Console.ReadLine()));

        }
            foreach (var numero in numeros)
            {
                Console.Write(numero);
            }

        Console.ReadKey();
    
answered by 07.11.2018 / 20:50
source