Last Updated : 11 Jul, 2025
Console.SetWindowPosition(Int32, Int32) Methodin C# is used to set the position of the console window relative to the screen buffer.
Syntax: public static void SetWindowposition(int left, int top); Parameters: left: It is the column position of the upper left corner of the console window. top: It is the row position of the upper left corner of the console window.Exceptions:
// C# Program to illustrate the use of
// Console.WindowPosition() method
using System;
using System.Text;
using System.IO;
class GFG {
// Main Method
public static void Main(string[] args)
{
Console.SetWindowSize(20, 20);
// setting buffer size
Console.SetBufferSize(80, 80);
// using the method
Console.SetWindowPosition(0, 0);
Console.WriteLine("Hello GFG!");
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
Output:
When
Console.WindowPosition()method is not used:
Reference:RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4