Mega Code Archive

 
Categories / C# / Reflection
 

Get App Setting String

using System; using System.Collections.Generic; using System.Text; using System.Configuration; public class Utils {     public static string GetAppSettingString(AppSettingsSection appSettings, string keyName)     {         string rc = null;         if (appSettings != null)         {             KeyValueConfigurationCollection settings = appSettings.Settings;             string[] names = appSettings.Settings.AllKeys;             foreach (string name in names)             {                 if (name == keyName)                 {                     rc = settings[name].Value;                 }             }         }         return rc;     } }