Skip to content

C# Examples

  • Home
  • About C#
    • C# Interview Questions and Answers for .NET Developers
    • Learn C#: A Practical Path Through the Examples
  • All Posts
  • Bootstrap 5 Examples
  • Contact

WinForms

Get the Width and Height of Any Window in C# with GetWindowRect

November 25, 2026October 10, 2014 by turgay

Read the position and size of any window, including other applications’ windows, with the GetWindowRect API in C#, plus the DPI and border traps.

Categories C# .NET, WinForms Tags C#, get window rectangle, windows api Leave a comment

Convert an Image to a Byte Array in C#

November 25, 2026September 2, 2014 by turgay

Turn a System.Drawing Image into a byte array in PNG, JPEG or its original format, and know when File.ReadAllBytes is the better answer.

Categories C# .NET, WinForms Tags C#, convert image, convert image to byte array, image to byte array 1 Comment

Convert a Byte Array to an Image in C#

November 25, 2026September 2, 2014 by turgay

Load an Image from a byte array in C# without the “generic error occurred in GDI+” trap, plus the WPF BitmapImage version.

Categories C# .NET, WinForms Tags byte array to image, C#, convert byte array, convert byte array to image 3 Comments

Let the User Pick a Font with FontDialog in C#

November 25, 2026July 12, 2014 by turgay

Show the WinForms FontDialog, preselect the current font, add color and a live Apply preview, and handle Cancel correctly.

Categories C# .NET, WinForms Tags C#, font dialog, FontDialog, select a font Leave a comment

Let the User Pick a Color with ColorDialog in C#

November 25, 2026July 12, 2014 by turgay

Show the WinForms ColorDialog, preselect a color, keep the user’s custom colors between calls and avoid the Color equality trap.

Categories C# .NET, WinForms Tags C#, color dialog, ColorDialog, pick a color Leave a comment
Older posts
Page1 Page2 Page3 Next →

Categories

Recent Posts

  • Select XML Nodes by Name or Attribute Value in C#
  • Binary Search Tree in C#: Add, Find, Remove and Traversals
  • Select, Insert, Update and Delete Data in an Access File with C#
  • C# Collections: Which One to Use and When
  • C# ArrayList vs Generic List: Examples and When to Use Each
  • About
  • Privacy Policy
  • Contact
© 2026 C# Examples