我有一个扩展方法,DropDownList
它会抛出Extension method can only be declared in non-generic, non-nested static classes
关键字this
。我不太清楚为什么,因为我已经看到很多关于扩展方法的例子DropDownList
public static class DropDownListExtensions {
public static void populateDropDownList(this DropDownList source, Action delegateAction) {
source.DataValueField = "Key";
source.DataTextField = "Value";
source.DataSource = delegateAction;
source.DataBind();
}
}