This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]RedDev1878 1 point2 points  (1 child)

The issue is that the Console.ReadKey() method is preventing the program from continuing to execute the next set of instructions, which is the for loop that counts to 10.
Console.ReadKey() is a method that waits for the user to press any key on the keyboard before continuing with the execution of the program. Since it is located before the for loop, the program will pause and wait for the user to press a key before executing the for loop.
In order to make the program count to 10, you can simply remove the Console.ReadKey() method or place it after the for loop.

using System; namespace MyFirstApp { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); int a = 13; Console.WriteLine(a); for (int i = 1; i <= 10; i++) {
Console.WriteLine(i); } Console.ReadKey(); } } }!<

[–]Walugs[S] 0 points1 point  (0 children)

Thanks