so my code displays data parsed form xml files to the console. How can I pause the Console Output box on the screen so I can read the data.
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, doubl开发者_如何学Pythone.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);
}
}
}
You could wait to accept a CR using:-
Console.ReadLine()
Not sure that I got question right but have you tried Console.ReadLine()? It exactly stops the console output and waiting for the input.
Also there are following useful methods:
- Console.Read() - Reads the next character from the standard input stream
- Console.ReadKey - Obtains the next character or function key pressed by the user.
You can write
Console.ReadKey();
and the program stops until you hit a key.
Use Console.ReadKey(true);
and it will wait for user input. So until you type something you can read the output.
Try this,
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++;
}
精彩评论