Mid Collections

Can a Dictionary in C# have a null key? Why or why not?

  • For reference types, null keys are not allowed — adding one throws an

ArgumentNullException.

  • For value types, keys must be non-nullable (like int, Guid).

This restriction ensures the integrity of hashing, which is used internally by the dictionary.

More from C# Programming Tutorial

All questions for this course