So, we've now seen how to set up configuration providers, but how exactly can we use these configuration values? Let's see in the following sections.
Getting and setting values explicitly
Remember that the .NET configuration allows you to set both reading and writing, both using the [] notation, as illustrated in the following code snippet:
var value = cfg["key"]; cfg["another.key"] = "another value";
Of course, setting a value in the configuration object does not mean that it will get persisted into any provider; the configuration is kept in memory only.
It is also possible to try to have the value converted to a specific type, as follows:
cfg["count"] = "0"; var count = cfg.GetValue<int>("count");
Don't forget that the value that you want to convert needs to be convertible from a string; in particular, it needs to...