Gets or sets the leftmost position of the console window area relative to the screen buffer.
Assembly: mscorlib (in mscorlib.dll)
The console represents a rectangular window into a larger rectangular buffer area. Both the window and the buffer are measured vertically by their number of rows and horizontally by their number of columns. The dimensions of the buffer area are defined by the BufferHeight and BufferWidth properties. The dimensions of the console area are defined by the WindowHeight and WindowWidth properties. The property determines which column of the buffer area is displayed in the first column of the console window. The value of the property can range from 0 to BufferWidth - WindowWidth. Attempting to set it to a value outside that range throws an ArgumentOutOfRangeException.
When a console window first opens, the default value of the property is zero, which indicates that the first column shown by the console corresponds to the first column (the column at position zero) in the buffer area. The default width of both the console window and the buffer area is 80 columns. This means that the property can be modified only if the console window is made narrower or the buffer area is made wider.
Note that if the width of the buffer area exceeds the width of the console window, the value of the property is automatically adjusted when the user uses the horizontal scroll bar to define the window's relationship to the buffer area.
The following example opens an 80-column console window and defines a buffer area that is 120 columns wide. It displays information on window and buffer size, and then waits for the user to press either the LEFT ARROW key or the RIGHT ARROW key. In the former case, it decrements the value of the property by one if the result is a legal value. In the latter case, it increases the value of the property by one if the result would be legal. Note that the example does not have to handle an ArgumentOutOfRangeException, because it checks that the value to be assigned to the property is not negative and does not cause the sum of the and WindowWidth properties to exceed the BufferWidth property value.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.