Console.BufferWidth Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the width of the buffer area.
public:
static property int BufferWidth { int get(); void set(int value); };
public static int BufferWidth { [System.Runtime.Versioning.UnsupportedOSPlatform("browser")] get; [System.Runtime.Versioning.SupportedOSPlatform("windows")] set; }
public static int BufferWidth { [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 BufferWidth { get; set; }
[<get: System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<set: System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member BufferWidth : 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 BufferWidth : int with get, set
static member BufferWidth : int with get, set
Public Shared Property BufferWidth As Integer
Property Value
The current width, in columns, of the buffer area.
- Attributes
Exceptions
The value in a set operation is less than or equal to zero.
-or-
The value in a set operation is greater than or equal to Int16.MaxValue.
-or-
The value in a set operation is less than WindowLeft + WindowWidth.
The user does not have permission to perform this action.
An I/O error occurred.
The set operation is invoked on an operating system other than Windows.
Examples
This example demonstrates the BufferHeight and BufferWidth properties. 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.
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.
'
Remarks
If a set operation decreases the value of the BufferWidth property, the rightmost columns are removed. For example, if the number of columns is reduced from 80 to 60, columns 60 through 79 of each row are removed.