【问题标题】:How to make HTML Helpers that supports generic type?如何制作支持泛型的 HTML Helpers?
【发布时间】:2010-06-01 10:51:16
【问题描述】:
public static class EmptyOrNullHelper public static string EmptyOrNull(this HtmlHelper helper, IQueryable(T) type) { //Code } }

【问题讨论】:

    标签: c# .net html helper


    【解决方案1】:

    像这样:

    public static class EmptyOrNullHelper
    {
    
        public static string EmptyOrNull<T>(this HtmlHelper helper, IQueryable<T> type)
        {
            //Code
        }
    
    }
    

    换句话说,为要在其参数之一中使用的方法指定通用参数。您不需要在正常调用方法的地方执行此操作,只需在声明中即可。

    【讨论】:

    • 换句话说,以完全相同的方式编写任何泛型方法。
    猜你喜欢
    • 2012-11-15
    • 2021-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-09
    相关资源
    最近更新 更多