App.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="factory" value="Abstract_Dactory.SummerSkinFactory"/>
</appSettings>
</configuration>
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;////导入命名空间(记得在解决方案资源管理器里的“引用”中添加“System.Configuration”)
namespace Abstract_Dactory
{
class Program
{
static void Main(string[] args)
{
//读取配置文件
string factoryType =ConfigurationManager.AppSettings["factory"];
Console.WriteLine(factoryType);
Console.ReadKey();
}
}
}