控制台窗口的输出是否有限制? [英] Is there a limit on the output of Console Window?

查看:98
本文介绍了控制台窗口的输出是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码:
该程序检查输入的2个数字及其总和是否可被2-9整数除,并显示剩余的可分解数字(不包括正在查看的数字).

Code:
This program checks if the 2 numbers entered and their sum are divisible by the numbers 2 - 9, and displays the remaining divisible numbers (excluding the one being reviewed).

static void Main(string[] args)
{
    for (int i = 2; i < 10; i++)
    {
        Challenge(2, 6, i);
    }
    Console.ReadLine();
}

static void Challenge(int num1, int num2, int Divisor)
{
    int sum = num1 + num2;
    bool SumDivisible = sum % Divisor == 0;
    bool num1Divisible = num1 % Divisor == 0;
    bool num2Divisible = num2 % Divisor == 0;

    int highNum = 80;
    List<int> NumbersDivisible = Enumerable.Range(1, highNum).Where(x => x % Divisor == 0).ToList();

    // Use the booleans to determine output.
    if (SumDivisible || num1Divisible || num2Divisible)
    {
        if (SumDivisible)
        {
            Console.WriteLine("The SUM ({0}) is divisible by {1}! \nThe remaining USABLE numbers for {1} are:\n", sum, Divisor);
            outputListExceptInt(NumbersDivisible, sum);
            //output
            Console.WriteLine("\n\n");
        }
        if (num1Divisible)
        {
            Console.WriteLine("The FIRST number ({0}) is divisible by {1}! \nThe remaining USABLE numbers for {1} are:\n", num1, Divisor);
            outputListExceptInt(NumbersDivisible, num1);
            //output
            Console.WriteLine("\n\n");
        }

        if (num2Divisible)
        {
            Console.WriteLine("The SECOND number ({0}) is divisible by {1}! \nThe remaining USABLE numbers for {1} are:\n", num2, Divisor);
            outputListExceptInt(NumbersDivisible, num2);
            //output
            Console.WriteLine("\n\n");
        }
    }
    else
    {
        Console.WriteLine("The NUMBERS chosen and their SUM are not divisble by {0}. \nThe USABLE numbers for {0} are:\n", Divisor);
        outputListExceptInt(NumbersDivisible);
        Console.WriteLine("\n\n");
    }
}

public static void outputListExceptInt(List<int> NumbersDivisibleByDivisor, int except = 0)
{
    var Numbers = except > 0 ? NumbersDivisibleByDivisor.Where(x => x != except) : NumbersDivisibleByDivisor;
    foreach (int num in Numbers)
    {
        Console.WriteLine(num);
    }
}

问题:
我发现,当我将范围(highNum)设置为超过89的任何值时,都会从窗口顶部截取明显的一部分:

Problem:
I'm finding that when I set the range (highNum) to anything over 89, a noticeable portion from the top of the window gets cut off:

highNum = 89:

highNum = 89:

highNum = 90:

highNum = 90:

它只是跳了一下就切断了6条线,我不确定为什么.

Its cutting off 6 lines just with that small jump, and I'm not sure why.

问题:
我最好的猜测是控制台窗口可以显示的输出必须有一定的限制.这是正确的还是其他原因导致了此问题?

Question:
My best guess is that there must be some limit on the output that can be displayed by the Console Window. Is this correct, or is something else causing this issue?

推荐答案

在控制台窗口中,单击默认值"

In a console window, click on Defaults

这将打开一个对话框,默认情况下,您可以在所有控制台窗口中设置回滚缓冲区的大小(保留的最大行数).

This opens a dialog box that allows you to set the scrollback buffer size (max number of lines to retain) by default in all of your console windows.

在我的屏幕快照中,它设置为9000,因为我经常将输出记录到控制台,有时需要能够向后滚动.

In my screenshot it is set to 9000 because I often log output to a console, and sometimes need to be able to scroll way back.

您还可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆