xxxxxxxxxx
var builder = new ConfigurationBuilder();
// add static values
builder.AddInMemoryCollection(new Dictionary<string, string>
{
{ "MyKey", "MyValue" },
});
// add values from a json file
builder.AddJsonFile("appsettings.json");
// create the IConfigurationRoot instance
IConfigurationRoot config = builder.Build();
string value = config["MyKey"]; // get a value
IConfigurationSection section = config.GetSection("SubSection"); //get a section