-4

我正在写一个关于日期时间的助手。

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.DatepickerFor(HtmlHelper, Expression>, object, EInputAddonPosition?, EInputGroupSize?, EDateTimePickerFormat?, bool?, string)' 必须声明一个主体,因为它没有标记为抽象、外部或部分

4

1 回答 1

1

静态方法需要方法体。

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

这将使您摆脱当前的错误,但请注意throw new 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();
    }
}
于 2018-02-06T14:57:07.740 回答