Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

C# get resolution size in x and y

  1. User

    C# get resolution size in x and y

  2. Assistant

    You can use the Screen class in C# to get the resolution size in x and y. Here's an example:

    using System;
    using System.Windows.Forms;
    
    class Program
    {
        static void Main()
        {
            int screenWidth = Screen.PrimaryScreen.Bounds.Width;
            int screenHeight = Screen.PrimaryScreen.Bounds.Height;
    
            Console.WriteLine("Resolution: {0} x {1}", screenWidth, screenHeight);
        }
    }
    

    This code retrieves the primary screen's resolution size and displays it in the console.