I'm just wondering if there is an exception class in the .NET Framework intended to signify that an internal error has occured. If there isn't, I'll simply define one, but if there is, I would like to use it.
There are some situations where code is reachable, at least as judged by the compiler, but in fact should never be reached. Consider the following example:
static public int GetElementIndex(XmlElement e)
XmlNode parent = e.ParentNode;
if (parent is XmlDocument) return 1;
int n = parent.ChildNodes.Count;
int idx = 0;
foreach (XmlNode child in parent.ChildNodes)
if (child is XmlElement && child.Name == e.Name)
if (child == e) return idx;
// If this line is ever reached, there is a bug somewhere!
View Complete Post