共用方式為


編譯器錯誤 CS1105

更新:2007 年 11 月

錯誤訊息

擴充方法必須為靜態。

擴充方法必須在非泛型靜態類別 (Class) 中宣告為靜態方法。

範例

因為 Test 不是靜態,所以下列範例會產生 CS1105:

// cs1105.cs
// Compile with: /target:library
public class Extensions
{
   
    // Single type parameter.
        public void Test<T>(this System.String s) {} //CS1105
    
}

請參閱

參考

擴充方法 (C# 程式設計手冊)

static (C# 參考)