新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
C#extern修飾符概述
C#語言還是比較常見的東西,這里我們主要介紹C# extern修飾符,包括介紹成員函數(shù)經(jīng)常用于系統(tǒng)API函數(shù)的調(diào)用等方面。

成都創(chuàng)新互聯(lián)主營金湖網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都APP應(yīng)用開發(fā),金湖h5微信小程序搭建,金湖網(wǎng)站營銷推廣歡迎金湖等地區(qū)企業(yè)咨詢
C# extern修飾符是什么意思?
C# extern修飾符用于聲明 由程序集外部實現(xiàn)的成員函數(shù)經(jīng)常用于系統(tǒng)API函數(shù)的調(diào)用(通過 DllImport )。注意,C# extern修飾符和DllImport一起使用時要加上 static 修飾符也可以用于對于同一程序集不同版本組件的調(diào)用(用 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);
- }
- }
- }
當(dāng)前文章:C#extern修飾符概述
URL鏈接:http://fisionsoft.com.cn/article/cceohoe.html


咨詢
建站咨詢
