Check if dictionary keys are declared, if not leave them as true I've tried with:

dictionary.TryGetValue("MoreDetails", out bool MoreDetails);


but if the key is not present it defaults to false, and I need it to default to true. Else I have this working implementation:

Dictionary&lt;string, bool&gt; CheckNullsSectionsVisibility(Dictionary&lt;string, bool&gt; dictionary)
{
    bool Summary = true;
    bool Backlog = true;
    bool MoreDetails = true;

    if (dictionary != null)
    {
        Summary = dictionary.ContainsKey("Summary") ? dictionary["Summary"] : true;
        Backlog = dictionary.ContainsKey("Backlog") ? dictionary["Backlog"] : true;
        MoreDetails = dictionary.ContainsKey("MoreDetails") ? dictionary["MoreDetails"] : true;
    };

    return new Dictionary&lt;string, bool&gt; {
        { "Summary", Summary},
        { "Backlog", Backlog},
        { "MoreDetails", MoreDetails}
    };
}


Is there a better approach? I don't like to repeat the true assignment, by the way.
TryGetValue returns True or False if it was found in the dictionary. I would suggest something like below. As it's still a single lookup in the dictionary to get the value but you can also set a default value other than default if it's not found in the dictionary.

bool moreDetails;
if !(dictionary.TryGetValue("MoreDetails", out moreDetails))
{
    moreDetails = true;
} 


Update to show extension method:

public static class DictionaryExtensions
{
    public static TValue TryGetWithDefaultValue&lt;TKey, TValue&gt;(this IDictionary&lt;TKey, TValue&gt; dictionary, TKey key, TValue defaultValue)
    {
        TValue value;
        if (!dictionary.TryGetValue(key, out value))
        {
            value = defaultValue;
        }
        return value;
    }
}


Then you could call it like:

var moreDetails = dictionary.TryGetWithDefaultValue("MoreDetails", true);