Search code examples
c#exceptionnullmsdnidictionary

IDictionary w/ Null Key - MSDN Typo or something else going on?


IDictionary<TKey, TValue>

ArgumentNullException - key is null.

Then, in the remarks...

Implementations can vary in whether they allow key to be null.

So, I have to wonder... is this an error or something I'm just missing here? The MSDN help file seems a bit contradictory.


Solution

  • What the documentation says is "If you get ArgumentNullException, then key was null".

    It does not say "If key is null, you get an ArgumentNullException." That would be an converse logic fallacy.

    The complete condition would be:

    "If and only if both key is null and the container does not support null keys, you get an ArgumentNullException."