小编nea*_*es1的帖子

使用LINQ选择一个字节数组

我在从对象列表中选择一个byte []时遇到一些麻烦,模型被设置为:

public class container{
    public byte[] image{ get;set; }
    //some other irrelevant properties    
}
Run Code Online (Sandbox Code Playgroud)

在我的控制器中我有:

public List<List<container>> containers; //gets filled out in the code
Run Code Online (Sandbox Code Playgroud)

我试图拉下image一个级别,List<List<byte[]>>所以到目前为止,我有一个使用LINQ:

var imageList = containers.Select(x => x.SelectMany(y => y.image));
Run Code Online (Sandbox Code Playgroud)

但它扔了:

cannot convert from 
'System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<byte>>' to 
'System.Collections.Generic.List<System.Collections.Generic.List<byte[]>>'  
Run Code Online (Sandbox Code Playgroud)

显然它是选择字节数组作为一个字节?

一些指导将不胜感激!

c# linq

3
推荐指数
1
解决办法
1656
查看次数

标签 统计

c# ×1

linq ×1