c# dictionary check if key exists before adding code example Example: c# check to see if dictionary key exists bool keyExists = dict.ContainsKey(key);