简体   繁体   中英

List the current processes in C# Console

I wanted to create a list of running in C# console,

I wrote this code:

var list = new List<int>(Process.GetProcesses());

What is proper way to make a list of current running processes in C# console ?

What is that int there? Process.GetProcesses() return an array of Process. For example:

void Main()
{
    foreach (Process p in Process.GetProcesses())
    {
        Console.WriteLine($"Id:{p.Id},Process: {p.ProcessName}");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM