我有清单:
ProjectTaskList = new SortedDictionary<string, SortedDictionary<string, string>>();
我尝试显示列表中的所有元素:
foreach (var itemList in ProjectTaskList)
{
Console.WriteLine("Value: " + itemList.Value + ", Key: " + itemList.Key);
}
如何显示嵌套
SortedDictionary<string, string>
中的元素? 最佳答案
要显示键,然后显示每个itemList
的所有键/值对:
foreach (var itemList in ProjectTaskList)
{
Console.WriteLine($"Key: {itemList.Key}");
foreach (var entry in itemList.Value)
{
Console.WriteLine($"Value: {entry.Value}, Key: {entry.Key}");
}
}
关于c# - 显示嵌套SortedDictionary中的元素,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54861160/