当前位置: 代码迷 >> C# >> c# List 怎么select 出非空的元素
  详细解决方案

c# List 怎么select 出非空的元素

热度:260   发布时间:2016-05-05 05:13:07.0
c# List 如何select 出非空的元素?
       List<string> ttt = new List<string>() { "1","2",""};
       ttt = ttt.Select(x => x != "").ToList();

提示:错误 1 无法将类型“System.Collections.Generic.List<bool>”隐式转换为“System.Collections.Generic.List<string>”  

------解决思路----------------------
select毛线呀

条件过滤要用where

select是一对一的映射
------解决思路----------------------
ttt.Where(x => x != "").ToList()

看下方法说明就知道了啊
  相关解决方案