外部方法
c#引入了extern修饰符来表示外部方法。外部方法是用c#以外的语言实现的方法如win32 api函数。如前所是外部方法不能是抽象方法。我们看下面的一个例子:
using system;
using system.runtime.interopservices;
class myclass
{
[dllimport("user32.dll")]
static extern int messageboxa(int hwnd, string msg,string caption, int type);
public static void main()
{
messageboxa(0, "hello, world!", "this is called from a c# app!", 0);
}
}
程序经编译后执行输出:
这里我们调用了win32 api函数int messageboxa(int hwnd, string msg,string caption, int type)。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器