Метод Console.SetBufferSize () в C #
Опубликовано: 2 Февраля, 2022
Console.SetBufferSize (Int32, Int32) Метод используется для установки высоты и ширины буферной области экрана на указанные значения.
Syntax: public static void SetBufferSize(int width, int height);
Parameters:
width: It sets the width of the buffer area measured in the form of columns.
height: It sets the height of the buffer area measured in the form of rows.Return value: The new size of the buffer screen.
Исключения:
- ArgumentOutOfRangeException: If the height or width is less than or equal to zero Or height or width is greater than or equal to MaxValue. Also, if the width is less than
WindowLeft + WindowWidth
or height is less thanWindowTop + WindowHeight
then we will get the same exception. - IOException: If an I/O error occurred.
Примечание. Как вы увидите с помощью горизонтальной и вертикальной полос прокрутки в приведенных ниже примерах, поскольку мы указываем разные размеры, мы получаем окна разного размера.
Example 1:
// C# program to demonstrate // the SetBufferSize Method using System; using System.Text; using System.IO; class GFG { // Main Method public static void Main() { // using the method Console.SetBufferSize(800, 800); Console.WriteLine( "Start" ); while ( true ) { Console.WriteLine( "Great Geek"s Example!!!" ); } } // end Main } |
Выход:
Example 2:
// C# program to demonstrate // the SetBufferSize Method using System; using System.Text; using System.IO; class GFG { // Main Method public static void Main() { Console.SetBufferSize(0, 80); Console.WriteLine( "Great Geek"s Example!!!" ); Console.WriteLine( "The Width"s value is too less!" ); } // end Main } |
Example 3:
// C# program to demonstrate // the SetBufferSize Method using System; using System.Text; using System.IO; class GFG { // Main Method public static void Main() { Console.SetBufferSize(8000, -80); Console.WriteLine( "Great Geek"s Example!!!" ); Console.WriteLine( "The negativity of this height is unbearable!" ); } // end Main } |
Ссылка:
- https://docs.microsoft.com/en-us/dotnet/api/system.console.setbuffersize?view=netframework-4.7.2