How can I detect if this dictionary key exists in C#?

You can use ContainsKey: if (dict.ContainsKey(key)) { … } or TryGetValue: dict.TryGetValue(key, out value); Update: according to a comment the actual class here is not an IDictionary but a PhysicalAddressDictionary, so the methods are Contains and TryGetValue but they work in the same way. Example usage: PhysicalAddressEntry entry; PhysicalAddressKey key = c.PhysicalAddresses[PhysicalAddressKey.Home].Street; if (c.PhysicalAddresses.TryGetValue(key, out … Read more