- Home /
Question by
Crystalline · Mar 26, 2014 at 03:51 PM ·
intvaluedictionarycompare
Comparing Dictionary values
Hi.
How do I compare a value from a dictionary with another one?
ex:
if(Dict("health") > 100)
Thanks.
Comment
Best Answer
Answer by frarees · Mar 26, 2014 at 03:54 PM
Using C#:
Dictionary<string, int> myDict = new Dictionary<string, int> ();
myDict.Add ("health", 150);
if (myDict["health"] > 100) {
...
}
This requires the namespace System.Collections.Generic
. See more here.
Thanks! The only issue was that I used () ins$$anonymous$$d of [].Thanks again.