Here's a snippet on how to retrieve running process in your computer by array names using LINQ.
C# Code
1
2
3
4
5
6
7
8 | List<Process> procs = new List<Process>();
procs = new List<string>() { "firefox", "iexplore", "ssms", "notepad++", "chrome" }
.SelectMany(o => Process.GetProcessesByName(o)).ToList();
foreach (var item in procs)
{
Console.WriteLine(item.ProcessName);
}
|
VB.NET
1
2
3
4
5
6 | Dim procs As IEnumerable(Of Process) = _
{"firefox", "iexplore", "ssms", "notepad++", "chrome"}.SelectMany(Function(proc) Process.GetProcessesByName(proc))
For Each p In procs
Console.WriteLine(p.ProcessName)
Next
Console.ReadLine()
|
Output
Comments
Post a Comment