MCQs > IT & Programming > C# > Which of the following code samples will execute a command-line program in C# and return its STD OUT results?

C# MCQs

Which of the following code samples will execute a command-line program in C# and return its STD OUT results?

Answer

Correct Answer: System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("program_to_call.exe"); psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; System.Diagnostics.Process proc System.Diagnostics.Process.Start(psi);; System.IO.StreamReader myOutput = proc.StandardOutput; proc.WaitForExit(2000); if (proc.HasExited) { string output = myOutput.ReadToEnd(); }

Explanation:

Note: This Question is unanswered, help us to find answer for this one

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

C# Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it