从进程列表中查找在指定的(存放在string数组中)进程:
Process[] curProcesslist = Process.GetProcesses();
//Use LINQ to query the object
var downProcess =
from process in aryProcessList
join processCur in curProcesslist
on process equals processCur.ProcessName.ToLower()+".exe" into newProcessList
from newprocess in newProcessList.DefaultIfEmpty()
select new
{
ProcessName = process,
ProcessInfo = newprocess == default(Process) ? null : newprocess
};
LINQ to Entities 中查询有些区别:
真省事:
顺便记个数组中查找及组合元素的: