Bueno, la par no puede existir si el clave no existe ... así buscar el valor asociado a la clave, y comprobar si ese es el valor que estaba buscando. Así, por ejemplo:
// Could be generic of course, but let's keep things simple...
public bool ContainsKeyValue(Dictionary<string, int> dictionary,
string expectedKey, int expectedValue)
{
int actualValue;
if (!dictionary.TryGetValue(expectedKey, out actualValue))
{
return false;
}
return actualValue == expectedValue;
}
o un poco más "inteligente" (por lo general algo para evitar ...):
public bool ContainsKeyValue(Dictionary<string, int> dictionary,
string expectedKey, int expectedValue)
{
int actualValue;
return dictionary.TryGetValue(expectedKey, out actualValue) &&
actualValue == expectedValue;
}
Uso TryGetValue lugar. – Marlon
¿Por qué buscar dos veces? –