Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将二进制数据流式传输到 .NET 中的标准输出。但是,您只能使用 Console 类编写 char 。我想将它与重定向一起使用。有没有办法做到这一点?
您可以使用 访问输出流Console.OpenStandardOutput。
Console.OpenStandardOutput
static void Main(string[] args) { MemoryStream data = new MemoryStream(Encoding.UTF8.GetBytes("Some data")); using (Stream console = Console.OpenStandardOutput()) { data.CopyTo(console); } }