文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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();
}
}

 

 

呵呵 菜鸟学习中……

 

 

 

 

相关阅读 更多 +
排行榜 更多 +
开心动动脑安卓版 v1.0 手机版

开心动动脑安卓版 v1.0 手机版

休闲益智 下载
不良人破局手游下载

不良人破局手游下载

角色扮演 下载
云海之下手游下载

云海之下手游下载

角色扮演 下载