Quantcast
Channel: Will ConfigurationManager.AppSettings["blah"] throw an exception if "blah" doesn't exist? - Stack Overflow
Browsing latest articles
Browse All 8 View Live

Image may be NSFW.
Clik here to view.

Answer by Scott Munro for Will ConfigurationManager.AppSettings["blah"] throw...

Other answers reference the documentation for the Item property. It might not be immediately obvious why they are relevant looking at the following code snippet....

View Article



Answer by Dexter for Will ConfigurationManager.AppSettings["blah"] throw an...

No, it returns null. AppSettings is a NameValueCollection - as per the caution on the NameValueCollection.Get page: This method returns a null reference (Nothing in Visual Basic) in the following...

View Article

Answer by Andrew for Will ConfigurationManager.AppSettings["blah"] throw an...

No, it returns null. ConfigurationManager.AppSettings is a NameValueCollection - from the MSDN documentation: The Get method does not distinguish between null which is returned because the specified...

View Article

Answer by Martin Liversage for Will ConfigurationManager.AppSettings["blah"]...

From the MSDN documentation for NameValueCollection.Item Property (String): Caution This property returns null in the following cases: 1) if the specified key is not found; and 2) if the specified key...

View Article

Answer by Tim Robinson for Will ConfigurationManager.AppSettings["blah"]...

No, it returns null.

View Article


Answer by Ben for Will ConfigurationManager.AppSettings["blah"] throw an...

Yes http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.appsettings.aspx Edit: this is clearly wrong. Left for the helpful comments below.

View Article

Will ConfigurationManager.AppSettings["blah"] throw an exception if "blah"...

Will ConfigurationManager.AppSettings["blah"] throw an exception if "blah" doesn't exist in the web/app.config? Sincere apologies for the super lazy question.

View Article

Answer by Kasper for Will ConfigurationManager.AppSettings["blah"] throw an...

As Tim said, it will just return null.However, if you want it to throw an exception when not found one could do this:var myImportantSetting= ConfigurationManager.AppSettings["important_setting"] ??...

View Article

Browsing latest articles
Browse All 8 View Live




Latest Images