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

屬性值

以資料列數測量的目前緩衝區高度。

屬性

例外狀況

設定作業中的值小於或等於零。

-或-

設定作業中的值大於或等於 Int16.MaxValue

-或-

設定作業中的值小於 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 行。

適用於