c# - Why can one null return be tested but another throws an exception? -


I want to test if looking at any XML attribute:

  XmlAttributeCollection PG_attrColl = Some nodores Features;  

This first test works:

  if (empty! = PG_attrColl ["SomeAttribute"])  

"GetNamedItem" is considered to be blank, but the following test is aborted after an exception complaint. / Code>

Why the difference? just curious.

if (empty! = PG_attrColl ["SomeAttribute"])

See here if the attribute is zero

if (null! = PG_attrColl.GetNamedItem ("SomeAttribute"). Value;)

You will see that the value of the attribute is zero. Code is trying to use the attribute first, which is zero, throwing exceptions.


Comments