- 2006年6月29日 22:55
構成ファイル(Web.config、App.config)の値を読み込む際に
[VB.NET - .NET2003]
myConfig = (NameValueCollection)ConfigurationSettings.AppSettings(strAddress);
myConfig = (NameValueCollection)ConfigurationSettings.GetConfig(strAddress);
こんな風に書いていた訳だが、そのままC#にコンバートしたらWarningが出た(泣)
警告'System.Configuration.ConfigurationSettings.AppSettings' は古い形式です: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'
Warningなので放置プレイでも良かったんだけど、そこはエンジニアとしてのプライドが...
[C# - VS2005]
myConfig = ConfigurationManager.AppSettings[strAddress];
myConfig = ConfigurationManager.GetSection[strAddress];
単純にConfigurationManagerに置き換えるだけかと思いきや、MSDNを見るとSystem.Configurationを参照に追加しないといけないみたい。
あと、GetConfigはGetSectionに。
usingはそのままでいいのに、変なの~
- Newer: セキュアド挑戦
- Older: C#とVB.NETとの違い(その1)
Comments:0
Trackbacks:0
- TrackBack URL for this entry
- http://magicbox.sakura.ne.jp/mt/mt-tb.cgi/66
- Listed below are links to weblogs that reference
- C#とVB.NETとの違い(その2) from 爆裂!C#野郎