c# 从local.config取值
时间: 2023-11-23 08:06:52 浏览: 35
在C#中从local.config取值,可以使用System.Configuration.ConfigurationManager类。以下是一个简单的示例代码:
```csharp
using System.Configuration;
// 读取local.config中的AppSettings值
string value = ConfigurationManager.AppSettings["key"];
```
在以上示例中,"key"是local.config文件中AppSettings节点下的一个键。你可以替换它为你需要读取的键名。需要注意的是,你需要在项目中添加System.Configuration引用才能使用ConfigurationManager类。