0

I have the sample console application whose code is given below

  static void Main(string[] args)
  {
      Console.Writeline("Enter any value");
      int x = int.Parse(Console.Readline());
      if( x%2 == 0)
         Console.Writeline("Even Value");
      else
         Console.Writeline("ODD Value");
  }

I want to display the console of this app in simple window form, I have displayed the output line, but was unable to figure out sending input to the console application, the code for window form

var info= new ProcessStartInfo("console.exe")
{
    UseShellExecute = false,
    RedirectStandardError = true,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
}
string line="";
using (Process process= Process.Start(info))
{
    using (StreamReader reader = process.StandardOutput)
    {
         while((line = reader.Readline()) != null)
              Console.Writeline(line);
    }
}
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.