Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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# 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List”_C#_Linq - Fatal编程技术网

C# 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List”

C# 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.List”,c#,linq,C#,Linq,但我收到一个错误报告,C无法转换列表: 错误:无法隐式转换类型 请用适当的解决方案指导我如何完成这一点,谢谢…以下几行创建了一个新的匿名对象,其中包含一个日期时间属性: 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<System.DateTime>' 尝试此操作以获取日期时间列表: select

但我收到一个错误报告,C无法转换列表:

错误:无法隐式转换类型


请用适当的解决方案指导我如何完成这一点,谢谢…

以下几行创建了一个新的匿名对象,其中包含一个日期时间属性:

'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<System.DateTime>'
尝试此操作以获取日期时间列表:

                         select new
                          {
                               Read_DATE = ((from mstdoc in mstdocs
                                               where
                                               mstdoc.docid == a.docid &&
                                                 mstdoc.vtype == "read"
                                               select new
                                               {
                                                    mstdoc.DCREA
                                              }).First().DCREA)
                            }

首先,你不能在同一个方法中定义两个同名的变量,比如List listdate和var listdate。你必须两次定义同一个变量,我是说listdate好的,我了解了变量:事实上嵌套的匿名对象也是多余的,可以删除,
                         select new
                          {
                               Read_DATE = ((from mstdoc in mstdocs
                                               where
                                               mstdoc.docid == a.docid &&
                                                 mstdoc.vtype == "read"
                                               select new
                                               {
                                                    mstdoc.DCREA
                                              }).First().DCREA)
                            }
                         select  ((from mstdoc in mstdocs
                                               where
                                               mstdoc.docid == a.docid &&
                                                 mstdoc.vtype == "read"
                                               select new
                                               {
                                                    mstdoc.DCREA
                                              }).First().DCREA)