开发者

How to make HTML Helpers that supports generic type?

开发者 https://www.devze.com 2023-01-02 00:27 出处:网络
public static class 开发者_Python百科EmptyOrNullHelper public static string EmptyOrNull(this HtmlHelper helper, IQueryable(T) type)

public static class 开发者_Python百科EmptyOrNullHelper

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

}


Like so:

public static class EmptyOrNullHelper
{

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

}

In other words, specify the generic parameter for the method that you want to use in one of its parameters. You'll not need to do this where the method is called normally, just in the declaration.

0

精彩评论

暂无评论...
验证码 换一张
取 消