using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using ClassLibrary1;
namespace ConsoleApplication1
{
class Program
{
[DllImport("ClassLibrary1.dll")]
extern static void showMessage();
static void Main(string[] args)
{
ClassLibrary1.Class1 i = new Class1();
i.showMessage();
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using ClassLibrary1;
namespace ConsoleApplication1
{
class Program
{
[DllImport("ClassLibrary1.dll")]
extern static void showMessage();
static void Main(string[] args)
{
ClassLibrary1.Class1 i = new Class1();
i.showMessage();
Console.ReadKey();
}
}
}
//Error 1 The DllImport attribute must be specified on a method marked 'static' and 'extern'
以下是库程序
静态函数里面只能调用静态变量,静态方法