Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 来自字典的转换错误<;日期时间、键值对<;DateTime,Business.Note>&燃气轮机;到字典<;日期时间,列表<;商业注释>&燃气轮机;_C#_.net - Fatal编程技术网

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);