Why doesn’t System.Xml.XmlReader.GetAttribute(String) throw an exception if the attribute is not found?! It seems ridiculous and dangerous at first sight.
Why doesn’t System.Xml.XmlReader.GetAttribute(String) throw an exception if the attribute is not found?! It seems
Share
Because there’s nothing “exceptional” about not finding a specified attribute. What if it’s optional? Would you then be relying on thrown exceptions to control your program flow?
This isn’t good practice – you should simply check the return value for null before using it.