c# - 编译器错误消息 : CS0118: 'System.Configuration.ConfigurationManager.AppSettings' is a 'property' but is used like a 'method'

标签 c# .net asp.net

编译器错误消息:CS0118:“System.Configuration.ConfigurationManager.AppSettings”是“属性”,但像“方法”一样使用

<add key="ObjConn" value="Provider=SQLOLEDB;Persist Security Info=True;User ID=OMembers;PWD=OMembers;Initial Catalog=Db;Data Source=""/>

 strconnection = System.Configuration.ConfigurationManager.AppSettings("ObjConn");
          sqlcon = new SqlConnection(strconnection);

最佳答案

C# 中,执行此操作:

strconnection = System.Configuration.ConfigurationManager.AppSettings["ObjConn"];
sqlcon = new SqlConnection(strconnection);

关于c# - 编译器错误消息 : CS0118: 'System.Configuration.ConfigurationManager.AppSettings' is a 'property' but is used like a 'method' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7484744/

相关文章:

c# - TextBlock 中动态字符串的 WPF 本地化

c# - .NET 中的随机和线程问题

asp.net - 代码优先迁移是否使用事务?

c# - 为什么我会得到这个 XML block 的 org.xml.sax.SAXException?

asp.net - ASP.NET MVC 中的 Post Action 分页问题

c# - 动态和 System.Object 之间的区别

c# - 如何从 WPF 应用程序线程显示 WinForms 模式对话框

c# 电子邮件对象流式传输到附件

c# - #if 除 DEBUG 之外的指令的预处理器指令

c# - int.Parse() 错误