con*_*att 2 .net c# asp.net-mvc .net-4.0
我正在关注.NET 4框架上的MVC教程.教程创建了这样的函数......
using System.Web;
using System.Web.Mvc;
namespace vohministries.Helpers
{
public static class HtmlHelpers
{
public static string Truncate(this HtmlHelper helper, string input, int length)
{
if (input.Length <= length)
{
return input;
}
else
{
return input.Substring(0, length) + "...";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道this HtmlHelper helper函数参数中的含义或代表.这是.NET 4中的新功能吗?我认为它可能会扩展HtmlHelper类,但我不确定......有人可以解释语法吗?
| 归档时间: |
|
| 查看次数: |
242 次 |
| 最近记录: |