引入Nuget的两个类库
Microsoft.Extensions.Configuration
Microsoft.Extensions.Configuration.Json
使用
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var configurationRoot = builder.Build();
var motherNameSection = configurationRoot.GetSection("mother").GetSection("name");
1660640-20190523152211549-903384370.png
网友评论