c# - Hashtable A equals HashtAble B control -


hallo in c# got 2 hashtable object of key/value pair same , want check if 2 hashtable key/value pairs equal..

i tried hashtable's equal method not worked

should check items foreach?

thanks

what want take set union , see if size same count. set difference you'd have both ways. these can done linq extension methods, since you're using hashtable have use cast() ienumerable:

        var table1 = new hashtable {{"a", 1}, {"b", 2}, {"c", 3}};         var table2 = new hashtable {{"b", 2}, {"a", 1}, {"c", 3}};          bool same = table1.cast<dictionaryentry>().union(table2.cast<dictionaryentry>()).count() == table1.count;          console.writeline("same = " + same); 

i typically recommend dictionary on hashtable type safety, cast<>() lets use linq stuff find old hashtable.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -