截取字符串

<%=CutString(product.Pro_Title,20) %>

页面类继承PageBase public partial class ProductListTable : Common.PageBase

namespace Common
{
public class PageBase
{

/// <summary>
/// 截取字符串
/// </summary>
/// <param name="content"></param>
/// <param name="length"></param>
/// <returns></returns>
protected static string CutString(string content, int length)
{
if (content.Length >= length)
{
content = content.Substring(0, length);
}

return content;
}

}

}

 

原文地址:https://www.cnblogs.com/mbtq/p/2665518.html