ContainsKey
ExamplesΒΆ
Determines if dictionary contains specific key element. Returns a bool
.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 | Dictionary<string, int> moons = new Dictionary<string, int>();
moons.Add("Mercury", 0);
moons.Add("Venus", 0);
moons.Add("Earth", 1);
moons.Add("Mars", 2);
moons.Add("Jupiter", 79);
moons.Add("Saturn", 82);
moons.Add("Uranus", 27);
moons.Add("Neptune", 14);
Console.WriteLine(moons.ContainsKey("Pluto"));
Console.WriteLine(moons.ContainsKey("Earth"));
|
Output
False
True