Title: Get the screen's resolution in C#
Normally a monitor displays 96 logical (or "notional") dots per inch (dpi) but it's not necessarily a good idea to assume that value. When this example starts, the following code displays the logical resolution of the screen in dpi.
private void Form1_Load(object sender, EventArgs e)
using (Graphics gr = this.CreateGraphics())
txtScreenHorizontal.Text = gr.DpiX.ToString() + " dpi";
txtScreenVertical.Text = gr.DpiY.ToString() + " dpi";
The code creates a Graphics object and then uses its DpiX and DpiY properties to get the horizontal and vertical resolution.
Note that logical dots per inch is not necessarily the same as actual dots per inch on the screen. That will also depend on the screen size and the resolution that you have selected. For example, my 15" screen can use resolutions between 800 x 600 pixels and 1366 x 768 pixels but they all report 96 dpi.
Download the example to experiment with it and to see additional details.