R – How to stream binary data to standard output in .NET


I'm trying to stream binary data to the standard output in .NET. However you can only write char using the Console class. I want to use it with redirection. Is there a way to do this?

Best Solution

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()) {