Difficulty: Easy
Correct Answer: True — a key cannot be null, but a value can be null.
Explanation:
Introduction / Context:
Hashtable stores key/value pairs with hashing semantics. Null handling differs for keys and values.
Concept / Approach:
Hashtable prohibits null keys because hashing and equality logic require a valid object reference. However, values may legitimately be null to represent “no value” while still reserving a key in the table.
Why Other Options Are Wrong:
Allowing a null key breaks hashing; disallowing null values is unnecessary; the comparer does not change the prohibition on null keys.
Final Answer:
True — a key cannot be null, but a value can be null.
Discussion & Comments