在你的工程中先要添加这个引用ConfigurationManager
<AppSettings>
<add key="config1" value="aaa" />
<add key="config2" value="bbb" />
</AppSettings>
string str = System.Configuration.ConfigurationManager.AppSettings["config1"].ToString();//str等于aaa
string str1 = System.Configuration.ConfigurationManager.AppSettings["config2"].ToString();//str1等于bbb