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

Post a Comment

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -