检查哈希表集合中是否存在键/值对

Laj*_*ker 2 c# hashtable

我有可憎的

Hashtable hash = new Hashtable();
hash.Add("a", "1");
hash.Add("b","2");
hash.Add("c","3");
hash.Add("c","4"
Run Code Online (Sandbox Code Playgroud)

现在我需要检查Key ="c"和value ="3"组合是否已经在哈希表中退出.

hash.ContainsKey值函数cheks天气键是否存在和ContainsValue功能检查天气值是否存在.但如果我试过

if( hash.Contains("c") && hash.ContainsValue("3"))
{
  // some code heree
}
Run Code Online (Sandbox Code Playgroud)

对于"c,3"和"c,4"组合,它将返回真实.

我需要检查键/值对组合,我该如何检查?

Jcl*_*Jcl 9

if(hash.ContainsKey("c") && hash["c"] == "3") { }
Run Code Online (Sandbox Code Playgroud)