Some Consistency, Please

Let’s look at the signatures for constructors of ArgumentNullException and ArgumentException:

public ArgumentException(
	string message,
	string paramName
)
public ArgumentNullException(
	string paramName,
	string message
)

Notice how they both take two string parameters, but each has opposite order. This drives me bonkers and I can never get the right one. I kind of wish MS would make a breaking change and fix it one way or the other.

Mixing numbers and replacement strings

This is yet another thing that I found took me too long to find on Google. I’m using the .NET regular expressions, and looking to replace values in a string with numbers, and I need to use the special $1 symbols to keep some of my capture groups around.

So, suppose I have the text:
something.2005.txt

The pattern:
(.*)2005(.*)

And the replacment string:
$12008$2

This produces the undesirable result $12008.txt. Why? Well, the $1 has to be escaped in some way. Whatever it is that scans for variables is obviously interpreting this as $12008 instead of $1; either that’s invalid or the group doesn’t exist so it just uses the text. Personally I think I should be getting “2008.txt” in this case, as a raw $ should take $$ to create, but I won’t complain.

The solution? Surround the number of the group index in brackets:
${1}2008$2

Windows ComboBox keyboard shortcuts

I use the keyboard a ton, and I found myself almost twice a week having to look up the keys to drop the menu in a ComboBox control. The right stuff tends to be buried in large documents, and I wasted a lot of time digging through them. No more! Now I can just check my blog, and hopefully Google will index it and others can find it more quickly.

F4 works, and so does ALT + DOWN. I like F4 better, because it can’t accidentally activate the window’s menu.