if else or dictionary c# code example Example: if in dictionary c# if (dict.ContainsKey(key)) { ... } //or dict.TryGetValue(key, out value);