Configuration section interface for accessing sub-trees.
The full path of this section.
string Path { get; }
Get a value relative to this section.
string? Get(string key)
T? Get<T>(string key)
Set a value relative to this section.
void Set(string key, string? value, int? targetLevel = null)
Get a child section.
ICfgSection GetSection(string key)
Get all child keys.
IEnumerable<string> GetChildKeys()
var dbSection = cfg.GetSection("Database");
// Read values
var host = dbSection.Get("Host");
var port = dbSection.Get<int>("Port");
// Nested section
var connSection = dbSection.GetSection("Connection");
var timeout = connSection.Get<int>("Timeout");
// Enumerate children
foreach (var key in dbSection.GetChildKeys())
{
Console.WriteLine($"{key}: {dbSection.Get(key)}");
}