Change log
- [#10] Added support for the C# 6 null conditional operator by changing the
Ini
indexer to return null
if the section is not found, instead of throwing the KeyNotFoundException
.
// Earlier code
string value = ini.TryGetValue("section", out var section) ? section["property"] : null;
if (value == null)
// Section does not exist
// With C# 6 null conditional operator
string value = ini["section"]?["property"];
if (value == null)
// Section does not exist
// Alternate non-C# 6 approach
var section = ini["section"];
string value = section != null ? section["property"] : null;
if (value == null)
// Section does not exist