I've got a Dictionary<TKey,TValue>
into which I'm inserting a lot of data. The keys are an enum. I keep getting this exception:
An item with the same key has already been added.
But I don't see any dupes, although I suspect some of my enums have the same value. Would that cause a duplicate key error? I thought an enum was a special type, so it's value wouldn't matter.
The exception isn't very helpful...it doesn't tell me which key is tripping the dupe. I'm using an initializer list.
Edit: Used some regex magic to convert my initializer list into separate .Add
calls. Found the key, but I'm still not seeing the dupe...
If multiple members of your enum has the same numeric representation that would be the cause of exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With