I can do this
IReadOnlySet<string> set = new HashSet<string>();
but I can't do this:
Dictionary<string, IReadOnlySet<string>> dictSet = new Dictionary<string, HashSet<string>>();
and I'm wondering why this is so?
Can this cast be done somehow or is it a case of having to create a whole new Dictionary? It seems rather inefficient to have to do this:
var dictSetPrep = new Dictionary<string, HashSet<string>>();
// Here we would add items to dictSetPrep
var dictSet = new Dictionary<string, IReadOnlySet<string>>();
foreach (var kvp in dictSetPrep) {
dictSet.Add(kvp.Key, kvp.Value);
}