文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>linq 从数组中排除部分项

linq 从数组中排除部分项

时间:2010-11-27  来源:醉眼

 

代码
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List
<string> depts = new List<string>();//所有部门
depts.Add("1");
depts.Add(
"2");
depts.Add(
"3");
depts.Add(
"4");
depts.Add(
"5");
depts
= DeptExclude1.Exclude(depts);
foreach (string d in depts)
{
Response.Write(d.ToString()
+"<br/>");
}

}
}

public class DeptExclude1
{
public static List<string> ex = new List<string>();//需要排除集合

public static List<string> Exclude(List<string> depts)
{
ex.Add(
"1");
ex.Add(
"2");
ex.Add(
"3");

return depts.Where(d=>ex.All(e=>e!=d)).ToList();
}
}

 

 

呵呵 菜鸟学习中……

 

 

 

 

相关阅读 更多 +
排行榜 更多 +
百炼英雄抽卡技巧指南

百炼英雄抽卡技巧指南

休闲益智 下载
英雄没有闪滚雷旋风技能如何搭配

英雄没有闪滚雷旋风技能如何搭配

休闲益智 下载
英雄没有闪雷旋风BD构筑推荐

英雄没有闪雷旋风BD构筑推荐

休闲益智 下载