Reputation: 327
I am trying to list these numbers like:
1. 114
2. 115
3. 116
etc.. The code I have right now is :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num = 0;
int count = 114;
while (count < 146)
{
Console.WriteLine(num + "." + count);
Console.Read();
count++;
}
}
}
}
The output I get is 0=114 and nothing after.. Please help
Upvotes: 0
Views: 120
Reputation: 2372
Using a for
loop:
static void Main(string[] args)
{
int num = 1;
for (int count = 114; count < 146; count++)
{
Console.WriteLine("{0}: {1}", num, count);
num++;
}
Console.Read();
}
If you had Console.Read()
inside the loop, you would need to hit the Enter key in order for the program to continue.
Upvotes: 2
Reputation: 15148
The Console.Read()
blocks the loop, so it should be:
static void Main(string[] args)
{
int num = 0;
int count = 114;
while (count < 146)
{
Console.WriteLine(num + "." + count);
count++;
}
Console.Read();
}
Upvotes: 3