Console.BufferWidth 属性

定义

获取或设置缓冲区的宽度。Gets or sets the width of the buffer area.

public:
 static property int BufferWidth { int get(); void set(int value); };
public static int BufferWidth { get; set; }
member this.BufferWidth : int with get, set
Public Shared Property BufferWidth As Integer

属性值

缓冲区的当前宽度,以列为单位。The current width, in columns, of the buffer area.

异常

Set 操作中的值小于或等于零。The value in a set operation is less than or equal to zero.

- 或 --or- 集运算中的值大于或等于 MaxValueThe value in a set operation is greater than or equal to MaxValue.

- 或 --or- Set 操作中的值小于 WindowLeft + WindowWidthThe value in a set operation is less than WindowLeft + WindowWidth.

用户没有执行此操作的权限。The user does not have permission to perform this action.

出现 I/O 错误。An I/O error occurred.

设置操作在 Windows 之外的操作系统上调用。The set operation is invoked on an operating system other than Windows.

示例

此示例演示 BufferHeightBufferWidth 属性。This example demonstrates the BufferHeight and BufferWidth properties. 该示例将报告操作系统窗口的尺寸,其缓冲区大小为300行,85列。The example reports the dimensions of an operating system window set to a buffer size of 300 rows and 85 columns.

// 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.
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.
'

注解

如果 set 操作减小 BufferWidth 属性的值,则会删除最右边的列。If a set operation decreases the value of the BufferWidth property, the rightmost columns are removed. 例如,如果列数从80减少到60,则将删除每行的60到79列。For example, if the number of columns is reduced from 80 to 60, columns 60 through 79 of each row are removed.

安全性

UIPermission
用于修改安全顶级窗口和子窗口。for modifying safe top-level windows and subwindows. 关联的枚举: SafeTopLevelWindowsAssociated enumeration: SafeTopLevelWindows

适用于