Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <add key="SiteTitle" value="Breaking News, World News, and Multimedia"/>
- <add key="SiteName" value="New York Times"/>
- <add key="somekey" value="somevalue"/>
- public string GetKeyThatHasMyValue (string Section, string ValueToFind)
- {
- string Result = null;
- var Settings = (NameValueCollection)ConfigurationManager.GetSection (Section);
- foreach (string Key in Settings.Keys)
- {
- if (Settings[Key].Contains (ValueToFind))
- {
- Result = Key;
- break;
- }
- }
- return Result;
- }
- using System.Collections.Specialized;
- NameValueCollection lstKeyValues;
- lstKeyValues = (NameValueCollection) ConfigurationManager.GetSection("YourSectionHere");
Add Comment
Please, Sign In to add comment