如何从输出过程类中读取最后一行?

Pio*_*r M 1 .net c# process

我正在使用Process类来启动一些进程,它正在计算一些数据并在它的控制台上提供输出,我需要阅读进程控制台的最后一行。应该怎么做?它与process.BeginOutputReadLine();但我不知道如何用于只读最后一行。

Ham*_*jam 5

string lastLine = null;
while (!process.StandardOutput.EndOfStream) 
{
    lastLine = process.StandardOutput.ReadLine();
}

//do what you want here with lastLine;
Run Code Online (Sandbox Code Playgroud)