Very nice tips indeed!
A somewhat different approach to this might be to use the
Debugger.IsAttached[
^]
static
property.
Though this works somewhat different.
if (System.Diagnostics.Debugger.IsAttached)
{
}
else
{
}
This looks more .NETish, but also performs differently as you can see.
I have used it many times for debugging purposes (for example, giving a value to a variable only for debugging).
Though not really a substitute for the above tips, I thought I should include this for completeness. :)