PropellerHead
PropellerHead

Reputation: 929

Showing multiple lines of text in a console application?

I need a way to show multiple lines of text (e.g. 1000 lines) in a console application, and be able to scroll through all lines. However, when I do something like the code snippet below, I can only see the last 100 or so lines in the console.

for (int i = 1; i <= 1000; i++)
{
   Console.WriteLine(i.ToString());
}

My initial though was to show a chuck of lines (e.g. 100 at a time), and let the user hit to browse further, but I've hoped there was an easier - and more userfriendly way?

Upvotes: 2

Views: 1659

Answers (1)

JaredPar
JaredPar

Reputation: 754505

If you want more control over the amount of lines which are scrollable in the Console, you can adjust the Console.BufferHeight property to be much larger. The value is the number of rows which are displayed. So if you set it to the number of lines, and assuming none of them wrap, your output will be scrollable.

Upvotes: 6

Related Questions