How to transfer binary data to standard output in .NET?

I am trying to pass binary data to standard output in .NET. However, you can only write char using the Console class. I want to use it with redirection . Is there any way to do this?

+4
source share
1 answer

You can access the output stream using Console.OpenStandardOutput .

  static void Main(string[] args) { MemoryStream data = new MemoryStream(Encoding.UTF8.GetBytes("Some data")); using (Stream console = Console.OpenStandardOutput()) { data.CopyTo(console); } } 
+6
source

Source: https://habr.com/ru/post/1276989/


All Articles