1

我收到一个错误,说底部不能大于或等于顶部。

我正在使用Rectangle此处记录的构造函数:https ://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.rectangle.-ctor?view=powershellsdk-1.1.0#System_Management_Automation_Host_Rectangle__ctor_System_Int32_System_Int32_System_Int32_System_Int32 _

这是我的相关代码部分;

            Console.WriteLine("setting rectangles: " + sizex +", " +sizey);
            int screenTop = sizey;
            int screenBottom = 1;
            int statusTop = 1;
            int statusBottom = 0;
            Console.WriteLine ("screen top bottom; "+screenTop + " > " + screenBottom );
            Console.WriteLine ("status top bottom; "+statusTop + " > " + statusBottom );
            
         // Rectangle(int left, int top, int right, int bottom);
            System.Management.Automation.Host.Rectangle screenWindowRect = new Rectangle(0,screenTop,sizex,screenBottom);
            System.Management.Automation.Host.Rectangle statusLineRect = new Rectangle(0,statusTop,sizex,statusBottom);
            Console.WriteLine("rectangles set");

我在构造函数之前看到了调试行,但从来没有看到“矩形集”消息。

这是输出;

setting rectangles: 241, 28
screen top bottom; 28 > 1
status top bottom; 1 > 0
Out-Less: "bottom" cannot be greater than or equal to "top".

我可以看到顶部大于底部,但我不断收到错误;"bottom" cannot be greater than or equal to "top"

这是一个错误,还是文档错误,还是我遗漏了什么。

4

1 回答 1

1

错误消息错误地陈述了实际的错误情况

"bottom" cannot be greater than or equal to "top"

应该:

"bottom" cannot be less than "top"

换句话说:参数bottom必须等于或大于top参数- 并且类似地right必须等于或大于 left

您可以在 PowerShell 本身中验证这一点:

# OK: 1 -ge 1
# Arguments are: left, top, right, bottom
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 1)

# OK: 2 -ge 1
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 2)

# !! EXCEPTION: 0 -ge 1 is NOT true.
[System.Management.Automation.Host.Rectangle]::new(0, 1, 0, 0)
于 2021-11-16T02:11:05.150 回答