下面的 C # 程序(使用 csc hello.cs
构建)只在控制台上打印 Hello via Console!
,在 DebugView 窗口中打印 Hello via OutputDebugString
。但是,我看不到任何一个 System.Diagnostics.*
调用。为什么?
using System;
using System.Runtime.InteropServices;
class Hello {
[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
public static extern void OutputDebugString(string message);
static void Main() {
Console.Write( "Hello via Console!" );
System.Diagnostics.Debug.Write( "Hello via Debug!" );
System.Diagnostics.Trace.Write( "Hello via Trace!" );
OutputDebugString( "Hello via OutputDebugString" );
}
}
csc
是否需要一些特殊的命令行开关?
我没有使用 VisualStudio 进行任何开发,这是纯命令行的东西。