Read values already printed to the console

后端 未结 4 1374
灰色年华
灰色年华 2021-01-18 12:32

This may be completely impossible, but I was wondering if there is a way to read values that the console has already printed. For example, if the console printed

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 12:48

    If you want to save what you are writing to the console, store it in a String variable first and then print the contents of this variable to the console, like so:

    String consoleOutput = "You are travelling north at a speed of 10m/s"
    Console.WriteLine(consoleOutput);
    

    That way you can access consoleOutput whenever you want.

提交回复
热议问题