所以我的代码将从xml文件解析的数据显示到控制台。如何暂停屏幕上的控制台输出框以便我可以读取数据。
var query = from file in fileEntries
let doc = XDocument.Load(file)
let x = doc.Descendants("XAxisCalib").Single()
let y = doc.Descendants("YAxisCalib").Single()
let z = doc.Descendants("ZAxisCalib").Single()
select new
{
XMax = x.Element("Max").Value,
XMin = x.Element("Min").Value,
YMax = y.Element("Max").Value,
YMin = y.Element("Min").Value,
ZMax = z.Element("Max").Value,
ZMin = z.Element("Min").Value
};
var results = from item in query
select new
{
XMaxResult = TryParseWithDefault(item.XMax, double.NaN) <= 290.0 ? "pass" : "fail",
XMinResult = TryParseWithDefault(item.XMin, double.NaN) >= -50.0 ? "pass" : "fail",
YMaxResult = TryParseWithDefault(item.YMax, double.NaN) <= 650.0 ? "pass" : "fail",
YMinResult = TryParseWithDefault(item.YMin, double.NaN) >= -89.0 ? "pass" : "fail",
ZMaxResult = TryParseWithDefault(item.ZMax, double.NaN) <= 20.0 ? "pass" : "fail",
ZMinResult = TryParseWithDefault(item.ZMin, double.NaN) >= -130.0 ? "pass" : "fail"
};
foreach (var result in results)
{
Console.WriteLine("XMaxResult = {0}", result.XMaxResult);
Console.WriteLine("XMinResult = {0}", result.XMinResult);
Console.WriteLine("YMaxResult = {0}", result.YMaxResult);
Console.WriteLine("YMinResult = {0}", result.YMinResult);
Console.WriteLine("ZMaxResult = {0}", result.ZMaxResult);
Console.WriteLine("ZMinResult = {0}", result.ZMinResult);
}
}
}
答案 0 :(得分:3)
您可以等待接受CR: -
到Console.ReadLine()
答案 1 :(得分:1)
我不确定我的问题是否正确但您是否尝过Console.ReadLine()? 它完全停止了控制台输出并等待输入。
还有以下有用的方法:
答案 2 :(得分:0)
你可以写
Console.ReadKey();
程序停止,直到你按下一个键。
答案 3 :(得分:0)
使用Console.ReadKey(true);
,它将等待用户输入。因此,在输入内容之前,您可以阅读输出。
答案 4 :(得分:0)
试试这个,
int count=1;
foreach (var result in results)
{
Console.WriteLine("XMaxResult = {0}", result.XMaxResult);
Console.WriteLine("XMinResult = {0}", result.XMinResult);
Console.WriteLine("YMaxResult = {0}", result.YMaxResult);
Console.WriteLine("YMinResult = {0}", result.YMinResult);
Console.WriteLine("ZMaxResult = {0}", result.ZMaxResult);
Console.WriteLine("ZMinResult = {0}", result.ZMinResult);
if(count%5==0)
Console.ReadLine();
count++;
}