2016-11-18 73 views
0
public static Hashtable ht = new Hashtable(); 

public static DateTime LoggedOn = DateTime.Now; 

ht.Add(message, LoggedOn);//message contains different sting messages for my logfile 

现在我想检查特定的消息是否存在,还有时间。 例如,我已经做了如何检查密钥和值是否已经存在于散列表

bool keyexists = ht.ContainsKey(message); 

bool valueexists = ht.ContainsValue(LoggedOn); 

,它将返回true,因为我已经添加它来hastable现在我要检查它是否添加了一个以上的时间,然后做一些事情..how我可以表明这样的事情? ?

回答

0

我不喜欢的东西:

bool exists = hash.Count(x => x.key == /* value to compare if exists*/) == 0 ? false : true 

    hash.ContainsKey(/* value to compare if exists*/)) 
    hash["c"] == /* value to compare if exists*/); 

例如从Dictonary也将努力为Hashtable的

相关问题