I am writing a Linq query just for learning.
var result = Process.GetProcesses()
.Where(p => p.WorkingSet64 > 20 * 1024 * 1024)
.OrderByDescending(p => p.WorkingSet64)
.Select(p => new {p.Id,p.ProcessName,p.WorkingSet64 });
I want to iterate in to result
foreach(process in result) //error-type or namespace process could not be found.
{
Console.WriteLine(Process.ProcessName);
}
I want to iterate in to result and print each process name on the console.
What I am doing wrong.
you’re close:
(I’m assuming you haven’t declared the name
processbefore.)Also note that if you use process (with a small p) in the foreach line, you need to keep the same case when you use it inside the loop.