C#语言还是比较常见的东西,这里我们主要介绍C# extern修饰符,包括介绍成员函数经常用于系统API函数的调用等方面。
成都创新互联主营金湖网站建设的网络公司,主营网站建设方案,成都APP应用开发,金湖h5微信小程序搭建,金湖网站营销推广欢迎金湖等地区企业咨询
C# extern修饰符是什么意思?
C# extern修饰符用于声明 由程序集外部实现的成员函数经常用于系统API函数的调用(通过 DllImport )。注意,C# extern修饰符和DllImport一起使用时要加上 static 修饰符也可以用于对于同一程序集不同版本组件的调用(用 extern 声明别名) 不能与 abstract 修饰符同时使用 。
示例:
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Runtime.InteropServices;
- namespace Example03
- {
- class Program
- {
- //注意DllImport是一个Attribute Property,
- //在System.Runtime.InteropServices命名空间中定义
- //extern与DllImport一起使用时必须再加上一个static修饰符
- [DllImport("User32.dll")]
- public static extern int
- MessageBox(int Handle, string Message, string Caption, int
- Type);
- static int Main()
- {
- string myString;
- Console.Write("Enter your message: ");
- myString = Console.ReadLine();
- return MessageBox(0, myString, "My Message Box", 0);
- }
- }
- }
分享题目:C#extern修饰符概述
URL标题:http://www.csdahua.cn/qtweb/news13/294863.html
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网