extern是什么意思
extern 修饰符用于声明由程序集外部实现的成员函数
经常用于系统API函数的调用(通过 DllImport )。注意,和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);
}
}
}
经常用于系统API函数的调用(通过 DllImport )。注意,和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);
}
}
}
【extern是什么意思】相关文章
1. extern是什么意思
3. what is the difference between ext2 and ext3
4. 在C++ 程序中调用被C 编译器编译后的函数,为什么要加extern "C"
5. 介绍一下ICMP(Internet Control Message Protocol)Internet控制信息协议
6. 软件测试LoadRunner面试题:What is the difference between standard log and extended log?
7. Spring中ApplicationContext的作用是什么
8. Java里面Pass by value和Pass by Reference是什么意思
9. 如何反序的迭代一个序列?how do I iterate over a sequence in reverse order
10. 停止劳动合同执行是什么意思?
本文来源:https://www.mianshiwenti.com/a12994.html
进入下载页面
上一篇:维德科技C#面试题笔试题
下一篇:C#笔试题
﹝extern是什么意思﹞相关内容
- 年底双薪是什么意思?
- 年终奖发13个月是什么意思?
- 年终奖拿13个月工资是什么意思?
- 能否解释一下XSS cookie盗窃是什么意思
- abstract是什么意思
- 在C语言中"指针和数组等价"到底是什么意思?
- Linux Interview Questions For software testers
- spring中的BeanFactory与ApplicationContext的作用和区别
- 如何在web环境中配置applicationContext.xml文件
- Spring里面applicationContext.xml文件能不能改成其他文件名