Does anyone have metrics on performing null test versus wrapping code in a try catch?
I suspect that the null test is much more efficient, but I don't have any empirical data.
The environment is C#/.net 3.x and the code comparison is:
Dude x = (Dude)Session["xxxx"];
x = x== null ? new Dude(): x;
versus
Dude x = null;
try {
x = (Dude)Session["xxxx"];
x.something();
} catch {
x = new Dude();
}
are there any advantages to wrapping in try catch?