Monthly Archives: December 2016

Five hats puzzle solution

If you haven’t read it yet, read the Five hats puzzle. Recall that the warden has three white hats and two black hats. If the first prisoner, Art, saw two black hats, then he would know that he had a … Continue reading

Posted in books, games, puzzles | Tagged , , , , , , , , , , , | Leave a comment

Five hats puzzle

This “hats puzzle” was described on December 26, 2016 on NPR’s Car Talk show. Sadly Tommy died in 2014 and the show was a rebroadcast so this puzzler has probably been used before. My book Interview Puzzles Dissected doesn’t include … Continue reading

Posted in books, games, puzzles | Tagged , , , , , , , , , , | Leave a comment

Convert a string to proper case (title case) in C#

In proper case (or title case) the first letter of each word is capitalized. This is actually pretty easy once you know where to find the method that converts to proper case. The example uses the following code to convert … Continue reading

Posted in strings | Tagged , , , , , , , , , , , | Leave a comment

Make TextBoxes automatically convert case in C#

It’s actually quite easy to make a TextBox convert case in .NET. Simply set the TextBox control’s CharacterCasing property to Lower or Upper. Then the control automatically converts alphabetic characters into the correct case. You can do this at design … Continue reading

Posted in controls, strings, user interface | Tagged , , , , , , , , , , , , | Leave a comment

See if Internet Explorer uses a proxy in C#

This example determines whether the system has Internet Explorer configured to use a proxy. Internet Explorer lets you specify proxy settings. In the Tools menu, select Internet Options. On the Connections tab, click the LAN Settings button. The goal of … Continue reading

Posted in internet, network, system | Tagged , , , , , , , , , , | Leave a comment

Move a window with a title that matches a pattern in C#

The example Set another application’s size and position in C# uses the FindWindow API function to find a window with a given title. Unfortunately FindWindow only finds the window if the title is an exact match. If you only know … Continue reading

Posted in API, miscellany, regular expressions, system | Tagged , , , , , , , , , , , , | Leave a comment

Tile desktop windows in rows and columns in C#

The example List desktop windows in C# shows how to list the currently running desktop windows. This example uses that technique to fill a ListBox with the titles of those desktop windows. (See the previous example to see how that … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , | Leave a comment

Set another application’s size and position in C#

When I write books, there is usually a maximum size that a screen shot can be. I wrote this program to make it easy to set an example program to exactly that size. This program uses the FindWindow API function … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | 3 Comments

Find a target window and minimize, maximize, or restore it in C#

This is the first in a series of posts that allow one application to manipulate a target window in another application. Note that this isn’t something that Microsoft really wants you to do. In general one application should not fiddle … Continue reading

Posted in API, miscellany, system | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Make a stopwatch in C#

This program is a simple stopwatch. When you click the Start button, the program changes the button’s caption to Stop and starts a Timer. As the stopwatch Timer runs, the program displays the elapsed time. Click the Stop button to … Continue reading

Posted in internationalization, miscellany, strings | Tagged , , , , , , , , , , , , , | Leave a comment