我需要修改以下C#程序,以讀取config.app中所有縮寫國名的所有三個字母,並將其列在winForm comboBox上,並從comboBox中進行選擇以更新相應地lbCountry.Text
和lbCurrencyRate.Text
。 我是新的C#,不知道如何更新app.config以下詳細信息,並基於組合框的選擇檢索它們。希望有人能幫忙。C#檢索基於comboBox選擇的app.config設置
國家縮寫:美國
國家名稱:美國
匯率:1.00
國家縮寫:AUS
國家名稱:澳大利亞
匯率:0.80
國家縮寫: GBR
國家名稱英國
匯率0.76
國家縮寫:JPN
國家名稱:日本
匯率:113.00
以下是最初創建檢索的app.config一個國家的細節部分代碼。
private void Main_Load(object sender, EventArgs e)
{
string countryName = ConfigurationManager.AppSettings.Get("COUNTRY_NAME");
string currencyRate = ConfigurationManager.AppSettings.Get("CURRENCY_RATE");
lbCountry.Text = string.Format("Country Name: {0}", countryName.ToString());
lbCurrencyRate.Text = string.Format("Currency Rate: {0}", currencyRate.ToString());
......
}
的App.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="COUNTRY_NAME" value="United States of America" />
<add key="CURRENCY_RATE" value="1.00" />
</appSettings>
......
</configuration>
更好地存儲在單獨的XML。 – Ramankingdom