How to make HTML Helpers that supports generic 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.
精彩评论