vs2005中讀配置文件的方法變了,比如說在winForm下讀app.config文檔吧,明明MSDN上說用:
System.Configuration.ConfigurationManager類,我日根本這個類都沒有。MSDN中還貼出了一些代碼:(C#)
// Create a custom section.
static UsingConfigurationManager()
{
// Get the application configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// If the section does not exist in the configuration
// file, create it and save it to the file.
if (config.Sections[customSectionName] == null)
{
custSection = new CustomSection();
config.Sections.Add(customSectionName, custSection);
custSection =
config.GetSection(customSectionName) as CustomSection;
custSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}你說這是什麼代碼,靜態方法沒有void 也沒有反回類型,不有上面的 as 關健字是什麼意思啊,
唉,真受不了vs2005。
System.Configuration.ConfigurationManager類,我日根本這個類都沒有。MSDN中還貼出了一些代碼:(C#)
// Create a custom section.
static UsingConfigurationManager()
{
// Get the application configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// If the section does not exist in the configuration
// file, create it and save it to the file.
if (config.Sections[customSectionName] == null)
{
custSection = new CustomSection();
config.Sections.Add(customSectionName, custSection);
custSection =
config.GetSection(customSectionName) as CustomSection;
custSection.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}你說這是什麼代碼,靜態方法沒有void 也沒有反回類型,不有上面的 as 關健字是什麼意思啊,
唉,真受不了vs2005。
解决方案 »
- 如何在GridView已有双击事件时,点击某行的某列时该单元格可以复制
- ToString("C")成为货币后如何再转为数字呢
- Visual C# 2005+SQL Server 2005数据库开发与实例
- 急救啊?搞得到的帮哈啊!
- 请问在C#中,用foreach如何将datatable
- 并发冲突:updatecommand影响了0个记录”错误
- webbrowser如何屏蔽弹出窗口及广告
- ASP.NET的系统在出现时怎么让系统显示指定的页面??
- 如何在windows服务中操作Excel载入宏?(多谢!)
- c#中的动画闪烁怎么办?用Bitblt?
- 合并DataSet 所有列
- 一个文件夹下的最大文件数目是多少?
MSDN上也說得很清楚啦
至于as是什麼意思,你還是找本講C#語法的書看看吧
果然是我沒加入參考,但是奇怪是沒加參考 System.Configuration 也會自出在IDE中出來。唉。
2.
as 是指類型轉換不丟異常,我剛看了一下MSDN,謝謝。
相當於下面語句的意思:
expression is type ? (type)expression : (type)null好,謝謝各位。給分了