Asp.net mvc 虽然static给出了一个错误

Asp.net mvc 虽然static给出了一个错误,asp.net-mvc,html-helper,mvchtmlstring,Asp.net Mvc,Html Helper,Mvchtmlstring,我正在写一封关于datetime的帮助信 public static class DatepickerHelper { public static MvcHtmlString Datepicker(this HtmlHelper htmlHelper, string name, object value = null, object htmlAttributes = null, EInputAddonPosition? addonPosition = EInputAddonPositio

我正在写一封关于datetime的帮助信

public static class DatepickerHelper
{
    public static MvcHtmlString Datepicker(this HtmlHelper htmlHelper, string name, object value = null, object htmlAttributes = null, EInputAddonPosition? addonPosition = EInputAddonPosition.Right, EInputGroupSize? groupSize = EInputGroupSize.Medium, EDateTimePickerFormat? Format = EDateTimePickerFormat.GunAyYil, bool? showRemoveButton = false, string onChangeFn = "");

    public static MvcHtmlString DatepickerFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes = null, EInputAddonPosition? addonPosition = EInputAddonPosition.Right, EInputGroupSize? groupSize = EInputGroupSize.Medium, EDateTimePickerFormat? Format = EDateTimePickerFormat.GunAyYil, bool? showRemoveButton = false, string onChangeFn = "");

    public static string GetStringValue(Enum value);
}
所有静态方法。。看起来有类似的错误,但我不明白

错误:

DatepickerHelper.DatepickerForHtmlHelper、表达式>、对象、EInputAddonPosition?、EInputGroupSize?、EdateTimePickerPerformat?、bool?、字符串“必须声明一个主体,因为它没有标记为抽象、外部或部分


静态方法需要一个方法体

您当前的实现实际上什么都不做

这将使您克服当前的错误,但请注意抛出新的NotImplementedException;-您需要实际实现该方法,并返回适当的值

public static class DatepickerHelper
{
    public static MvcHtmlString Datepicker(this HtmlHelper htmlHelper, string name, object value = null, object htmlAttributes = null, EInputAddonPosition? addonPosition = EInputAddonPosition.Right, EInputGroupSize? groupSize = EInputGroupSize.Medium, EDateTimePickerFormat? Format = EDateTimePickerFormat.GunAyYil, bool? showRemoveButton = false, string onChangeFn = "")
    {
        //notice there's a body to this static method now
        throw new NotImplementedException();
    }


    public static MvcHtmlString DatepickerFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes = null, EInputAddonPosition? addonPosition = EInputAddonPosition.Right, EInputGroupSize? groupSize = EInputGroupSize.Medium, EDateTimePickerFormat? Format = EDateTimePickerFormat.GunAyYil, bool? showRemoveButton = false, string onChangeFn = "")
    {
        //notice there's a body to this static method now
        throw new NotImplementedException();
    }

    public static string GetStringValue(Enum value)
    {
        //notice there's a body to this static method now
        throw new NotImplementedException();
    }
}

错误信息非常清楚。您已经创建了一些方法,但它们没有主体,并且因为它们没有标记为抽象,所以您得到了一个错误。我不确定您是否理解静态的含义,您是否将抽象与静态混淆?作为静态标记还不够吗。我问是因为我不明白。我问是因为我不明白我必须做什么。错误信息非常清楚。>是的,我明白了,但我不明白错误信息是非常清楚的。>是的,我明白了,但我不明白。