【发布时间】:2010-08-07 04:41:47
【问题描述】:
我正在关注 .NET 4 框架上的 tutorial on 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) + "...";
}
}
}
}
我不知道this HtmlHelper helper 在函数参数中的含义或表示。这是 .NET 4 中的新功能吗?我认为它可能会扩展 HtmlHelper 类,但我不确定......有人可以解释一下语法吗?
【问题讨论】:
标签: c# .net asp.net-mvc .net-4.0