So I wrote a parser that takes a string and deserializes it to a tree of values.
It was running very slow during debug.
I did some research and found most people said to open the output window and watch for exceptions.
I did that and saw a lot of system.format exceptions.
So I went to the debug exceptions dialog and checked all items.
That stopped the code on the subroutine making the exceptions.
It was my number test, looked like:
public static bool IsNumber(this string strNumber) {
try {
Convert.ToDouble(strNumber);
return true;
}
catch {
return false;
}
}
changed it to:
public static bool IsNumber(this string strNumber) {
double result;
return double.TryParse(strNumber, out result);
}
and no more format exceptions, and debug runs super fast now.
The moral of the story is little functions you use a lot should avoid using try - catch if it will be very common to get to the catch potion.
Experienced people will laugh at this experiment, but I've never heard anyone mention exceptions slow debug way down, so may help others.
internal protected virtual unsafe Human() : mostlyHarmless
I'm just here for the Shelties