C# 来自字典的转换错误<;日期时间、键值对<;DateTime,Business.Note>&燃气轮机;到字典<;日期时间,列表<;商业注释>&燃气轮机;
这是我的代码:C# 来自字典的转换错误<;日期时间、键值对<;DateTime,Business.Note>&燃气轮机;到字典<;日期时间,列表<;商业注释>&燃气轮机;,c#,.net,C#,.net,这是我的代码: Dictionary<DateTime, List<Business.Note>> testData = new Dictionary<DateTime, List<Business.Note>>(); //code emitted for abbreviation on how this dictionary is filled up var groupedData = testData.GroupBy(d => {
Dictionary<DateTime, List<Business.Note>> testData = new Dictionary<DateTime, List<Business.Note>>(); //code emitted for abbreviation on how this dictionary is filled up
var groupedData = testData.GroupBy(d => {
if (d.Key == today)
return "Today";
return "Other";
});
Dictionary<DateTime, List<Business.Note>> testData2 = groupedData.First().ToDictionary(g => g.Key); //this line gives compile time error
Dictionary testData=newdictionary()//关于如何填写本词典的缩写代码
var groupedData=testData.GroupBy(d=>{
如果(d.Key==今天)
返回“今天”;
返回“其他”;
});
Dictionary testData2=groupedData.First().ToDictionary(g=>g.Key)//这一行给出编译时错误
我的最终目标是在testData2中获取字典
,但目前我获取的错误不能隐式地从字典
转换为字典
如何解决此问题?因为您使用的是
groupedData.First()。ToDictionary
您的字典现在包含:g.Key);
Dictionary<DateTime, List<Business.Note>> testData2 = groupedData.First().ToDictionary(g => g.Key);
Dictionary<DateTime, List<Business.Note>> testData2 = groupedData.ToDictionary(g => g.Key);
Dictionary<DateTime, Business.Note> testData2 = groupedData.First().ToDictionary(g => g.Key);