Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <add key="SiteTitle" value="Breaking News, World News, and Multimedia"/>
  2. <add key="SiteName" value="New York Times"/>
  3. <add key="somekey" value="somevalue"/>
  4.  
  5. public string GetKeyThatHasMyValue (string Section, string ValueToFind)
  6. {
  7. string Result = null;
  8. var Settings = (NameValueCollection)ConfigurationManager.GetSection (Section);
  9. foreach (string Key in Settings.Keys)
  10. {
  11. if (Settings[Key].Contains (ValueToFind))
  12. {
  13. Result = Key;
  14. break;
  15. }
  16. }
  17.  
  18. return Result;
  19. }
  20.  
  21. using System.Collections.Specialized;
  22.  
  23. NameValueCollection lstKeyValues;
  24. lstKeyValues = (NameValueCollection) ConfigurationManager.GetSection("YourSectionHere");
Add Comment
Please, Sign In to add comment