C#2.0
|
源代码网整理以下extern 修饰符用于声明在外部实现的方法。extern 关键字常用于定义外部程序集别名,使得可以从单个程序集中引用同一组件的不同版本。 源代码网整理以下[DllImport("avifil32.dll")] 源代码网整理以下private static extern void AVIFileInit();在该示例中,程序接收来自用户的字符串并将该字符串显示在消息框中。程序使用从 User32.dll 库导入的 MessageBox 方法。using System; 源代码网整理以下using System.Runtime.InteropServices; 软件开发网 www.mscto.com 源代码网整理以下class MainClass 源代码网整理以下{ 源代码网整理以下 [DllImport("User32.dll")] 源代码网整理以下 public static extern int MessageBox(int h, string m, string c, int type); 源代码网整理以下 源代码网整理以下 static int Main() 源代码网整理以下 { 源代码网整理以下 string myString; 源代码网整理以下 Console.Write("Enter your message: "); 源代码网整理以下 myString = Console.ReadLine(); 软件开发网 www.mscto.com 源代码网整理以下 return MessageBox(0, myString, "My Message Box", 0); 源代码网整理以下 } 源代码网整理以下} 软件开发网 www.mscto.com 源代码网整理以下 源代码网整理以下 源代码网推荐 源代码网供稿. |
