I just asked this in a performance chat w/ Rico. It might be of use to some developers that are curious about these sorts of things…
Q: Hey Rico. How much of a performance difference is there between boxing vs. parsing. For instance:
return (bool)ViewState["myvar"];
vs.
return bool.parse(ViewState["myvar"].ToString());
A: Parsing is a total disaster compared to boxing. ToString will make a string then it will be parsed. Actually in that example there’s just unboxing which is really cheap. Very few cases of boxing would ever be more expensive than making a temp string — it’s not *that* bad to box
This was mainly due to an FxCop rule that says that it is bad to box values. Apparently this is one case where boxing is much better than the alternative.