下面的代码示例演示如何使用 AppSettings 属性获取命名的应用程序设置。
例子:
// Get appSettings. static void GetAppSettings() { // Get the appSettings. NameValueCollection appSettings = ConfigurationManager.AppSettings; // Get the collection enumerator. IEnumerator appSettingsEnum = appSettings.Keys.GetEnumerator(); // Loop through the collection and // display the appSettings key, value pairs. int i = 0; Console.WriteLine("App settings."); while (appSettingsEnum.MoveNext()) { string key = appSettings.Keys[i]; Console.WriteLine("Name: {0} Value: {1}", key, appSettings[key]); i += 1; } }
浙公网安备 33010602011771号