外部方法
C#引入了extern修饰符来表示外部方法。外部方法是用C#以外的语言实现的方法如Win32 API函数。如前所是外部方法不能是抽象方法。我们看下面的一个例子:
using System; public static void Main() |
程序经编译后执行输出:
这里我们调用了Win32 API函数int MessageBoxA(int hWnd, string msg,string caption, int type)。