I have opened five notepad.exe’s. Now I want to know all the process id’s associated with each notepad.exe.
I know I can retrieve list of notepad processes by:
Process[] processes = Process.GetProcessesByName(“notepad”);
But now I want string[] of process Id’s of those notepad instances using LINQ. How do I do that? I know i can create string[] and using foreach loop populate the string[] but I would like to know using LINQ.
You can use:
However, I question the need to put this into a
string[]type. It might be better to just leave the Process.Id values as integers: