[英]List the current processes in C# Console
I wanted to create a list of running in C# console, 我想创建一个在C#控制台中运行的列表,
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 ? 在C#控制台中列出当前正在运行的进程的正确方法是什么?
What is that int there? 那是什么int? Process.GetProcesses() return an array of Process.
Process.GetProcesses()返回一个Process数组。 For example:
例如:
void Main()
{
foreach (Process p in Process.GetProcesses())
{
Console.WriteLine($"Id:{p.Id},Process: {p.ProcessName}");
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.