Console.BufferHeight 属性

定义

获取或设置缓冲区的高度。

public:
 static property int BufferHeight { int get(); void set(int value); };
public static int BufferHeight { [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static int BufferHeight { [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] [System.Runtime.Versioning.UnsupportedOSPlatform("android")] [System.Runtime.Versioning.UnsupportedOSPlatform("ios")] [System.Runtime.Versioning.UnsupportedOSPlatform("tvos")] get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static int BufferHeight { get; set; }
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member BufferHeight : int with get, set
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("android")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member BufferHeight : int with get, set
static member BufferHeight : int with get, set
Public Shared Property BufferHeight As Integer

属性值

缓冲区的当前高度,以行为单位。

属性

例外

Set 操作中的值小于或等于零。

设置操作中的值大于或等于 Int16.MaxValue

Set 操作中的值小于 WindowTop + WindowHeight

用户没有执行此操作的权限。

出现 I/O 错误。

设置操作在 Windows 之外的操作系统上调用。

示例

此示例演示 BufferHeightBufferWidth 属性。 该示例报告设置为 300 行和 85 列的缓冲区大小的操作系统窗口的尺寸。

// This example demonstrates the Console.BufferHeight and 
//                               Console.BufferWidth properties.
using namespace System;
int main()
{
   Console::WriteLine( "The current buffer height is {0} rows.", Console::BufferHeight );
   Console::WriteLine( "The current buffer width is {0} columns.", Console::BufferWidth );
}

/*
This example produces the following results:

The current buffer height is 300 rows.
The current buffer width is 85 columns.
*/
// This example demonstrates the Console.BufferHeight and
//                               Console.BufferWidth properties.
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine("The current buffer height is {0} rows.",
                      Console.BufferHeight);
    Console.WriteLine("The current buffer width is {0} columns.",
                      Console.BufferWidth);
    }
}
/*
This example produces the following results:

The current buffer height is 300 rows.
The current buffer width is 85 columns.
*/
// This example demonstrates the Console.BufferHeight and
//                               Console.BufferWidth properties.
open System

printfn $"The current buffer height is {Console.BufferHeight} rows."
printfn $"The current buffer width is {Console.BufferWidth} columns."

// This example produces the following results:
//
// The current buffer height is 300 rows.
// The current buffer width is 85 columns.
' This example demonstrates the Console.BufferHeight and 
'                               Console.BufferWidth properties.
Class Sample
   Public Shared Sub Main()
      Console.WriteLine("The current buffer height is {0} rows.", _
                        Console.BufferHeight)
      Console.WriteLine("The current buffer width is {0} columns.", _
                        Console.BufferWidth)
   End Sub
End Class
'
'This example produces the following results:
'
'The current buffer height is 300 rows.
'The current buffer width is 85 columns.
'

注解

此属性定义 (行数或) 存储在控制台模式窗口访问的缓冲区中的行数。 相比之下, WindowHeight 属性定义在任何特定时间在控制台窗口中实际显示的行数。 如果实际写入缓冲区的行数超过了 属性定义的 WindowHeight 行数,则可以垂直滚动窗口,以便它显示等于 WindowHeight 属性且位于缓冲区中的任何位置的连续行数。

如果设置操作减小属性的值 BufferHeight ,则删除最上面的行。 例如,如果行数从 300 减少到 250,则删除行 0 到 49,现有行 50 到 299 将成为第 0 行到 249 行。

适用于