[英]Writing to the console's standard output using StreamWriter
Disclaimer: I come from a C++ background and started C# recently. 免责声明:我来自C ++背景,最近开始使用C#。
For some reason, I cannot write to the console's standard output like this: 由于某些原因,我无法像这样写控制台的标准输出:
new StreamWriter(Console.OpenStandardOutput()).Write("Stackoverflow");
Any suggestions? 有什么建议么?
sw = new StreamWriter(Console.OpenStandardOutput());
sw.AutoFlush = true;
Console.SetOut(sw);
sw.WriteLine("Stackoverflow");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.