我想通过列表中的元素在嵌套字典的数量进行排序字典值: VAR evantData =新词典>>()排序字典通过在列表elemnts的数目是用于嵌套字典
这是我的代码..
var evantData = new Dictionary<string, Dictionary<string, List<string>>>
();
string input = "";
while ((input=Console.ReadLine())!="Time for Code")
{
string[] evantAndParticipants = input.Split().Select(x => x.Trim()).ToArray();
if (!evantData.ContainsKey(evantAndParticipants[0]))
{
evantData.Add(evantAndParticipants[0],new Dictionary<string, List<string>>());
evantData[evantAndParticipants[0]].Add(evantAndParticipants[1], new List<string>());
}
evantData[evantAndParticipants[0]][evantAndParticipants[1]].AddRange(evantAndParticipants.Skip(2));
}
foreach (var item in evantData)
{
foreach (var evant in item.Value)
{
Console.WriteLine(evant.Key+" - {0}",evant.Value.Count);
Console.WriteLine(string.Join("\r\n",evant.Value));
}
}
我要排序的出来的元素在列表中的号码
什么是quesiton?显示您的代码 – Sajeetharan
排序字典?????没有这样的概念作为散列表/字典中的元素的顺序。我建议你熟悉存在的基本数据结构以及它们的常见操作,以及它们在什么情况下有用。 –
好的,按列表中的元素数量排序 –