I am trying to read a value of one key from a dictionary like the following:
If (myDic ["myKey"] = null) {} I can see that I am checking the blank, but still throws this KeyNotFoundException. How should I check more? Please advise!
It seems that you are confusing the behavior of HashTable Code> Dictionary & lt; Vaccines, televisions & gt; With . The HashTable class will return an null value when the key will not be present, while the dictionary & lt; Vaccine, tv, gt; will throw an exception. You have to use either included or TryGetValue to avoid this problem object Values; If (myDic.TryGetValue ("apple", outside values)) {...}
Comments
Post a Comment