要通过Console获取标准输出流,代码如下-
using System; public class Demo { public static void Main(string[] args){ Console.WriteLine("Standard Output Stream = "+Console.Out); } }
输出结果
这将产生以下输出-
Standard Output Stream = System.IO.TextWriter+SyncTextWriter
要通过控制台获取标准错误输出流,代码如下-
using System; public class Demo { public static void Main(string[] args){ Console.WriteLine("Standard Output Stream = "+Console.Out); Console.WriteLine("Standard Error Output Stream = "+Console.Error); } }
输出结果
这将产生以下输出-
Standard Output Stream = System.IO.TextWriter+SyncTextWriter Standard Error Output Stream = System.IO.TextWriter+SyncTextWriter