編譯器警告 (層級 1) CS0626
更新:2007 年 11 月
錯誤訊息
方法、運算子或存取子 'method' 被標記為外部而且上面沒有屬性。請考慮加入 DllImport 屬性來指定外部實作
標記 extern 的方法也應標示屬性,例如,DllImport 屬性。
此屬性會指定在何處實作方法。程式將會在執行階段時使用此資訊。
下列範例會產生 CS0626:
// CS0626.cs
// compile with: /warnaserror
using System.Runtime.InteropServices;
public class MyClass
{
static extern public void M(); // CS0626
// try the following line
// [DllImport("mydll.dll")] static extern public void M();
public static void Main()
{
}
}