c# - localSettings.Containers[containername] - The given key was not present -


i looping through code looking localsettings. when container null gives error message "the given key not present in dictionary". how can check see container null doesn't crash code?

if ((windows.storage.applicationdatacontainer)localsettings.containers[containername] != null) 

this gives same error

var container = localsettings.containers[containername]; 

windows.storage.applicationdatacontainer settings = windows.storage.applicationdata.current.localsettings;          //this checks if given container name exists or not         if(settings.containers.containskey("containername"))         {              if(settings.containers["containername"].values.containskey("your data key"))             {                 //do             }         } 

hope helps


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -