I am using CsvHelper
, which uses a TextWriter
to write its output. Instead of writing to a file, I would like to write the contents to the console. How can I get a TextWriter
that will write to the console?
Use the Console.Out
property to get the TextWriter
for the console, like so:
var textWriter = Console.Out;
using (var csvWriter = new CsvWriter(textWriter))
{
csvWriter.WriteRecords(records);
textWriter.Flush();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With