Framework

How to store null key in Generic Dictionary<TKey, TValue>

I was writing a cache optimized permit manager in ASPSecurityKit that stores entityIds as keys and list of permissions as values to reduce session size stored in Redis by 90%. In tests, I was using Nullable Guid? as the key type and it failed spectacularly with this exception: System.ArgumentNullException : Value cannot be null. Parameter name: key Researching about it, I stumbled on this SO question and this MSDN spec for Dictionary<TKey, TValue>.

Continue reading