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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -