Is it possible in C#7 to use deconstruction in a foreach-loop over a Dictionary? Something like this:
var dic = new Dictionary<string, int>{ ["Bob"] = 32, ["Alice"] = 17 };
foreach (var (name, age) in dic)
{
Console.WriteLine($"{name} is {age} years old.");
}
It doesn't seem to work with Visual Studio 2017 RC4 and .NET Framework 4.6.2:
error CS1061: 'KeyValuePair' does not contain a definition for 'Deconstruct' and no extension method 'Deconstruct' accepting a first argument of type 'KeyValuePair' could be found (are you missing a using directive or an assembly reference?)