【问题标题】:Redirecting console to a string in a .NET program将控制台重定向到 .NET 程序中的字符串
【发布时间】:2010-03-17 23:26:29
【问题描述】:

如何将写入控制台的内容重定向到字符串中?

【问题讨论】:

    标签: c# string console


    【解决方案1】:

    对于您自己的进程,Console.SetOut 并将其重定向到构建在字符串构建器或内存流之上的 TextWriter。对于已启动的子进程,在启动该进程时使用ProcessStartInfo.RedirectStandardOutput

    【讨论】:

      【解决方案2】:

      使用Console.SetOut ();

      【讨论】:

        【解决方案3】:
        string consoleString = Console.ReadLine();
        

        【讨论】:

          猜你喜欢
          • 2012-02-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-08-21
          • 2023-03-20
          • 1970-01-01
          相关资源
          最近更新 更多