博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

字符串截取

Posted on 2006-10-17 19:13  hnboy  阅读(178)  评论(0编辑  收藏  举报
    public string MyLeftFunction(string str, int Int)
    
{
        
if (str.Length <= Int)
        
{
            
return str;
        }

        
else
        
{
            str 
= str.Substring(0, Int) + "";
            
return str;
        }

    }

前台

<%# MyLeftFunction(DataBinder.Eval(Container, "DataItem.Title").ToString(),20) %>

20是显示的字数