Mid
From PDF
Collections
C# 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
rgumentNullException.
- 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.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png