欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET兩個截取字符串的方法分享

 更新時間:2013年11月08日 16:32:02   作者:  
這篇文章介紹了ASP.NET兩個截取字符串的方法,有需要的朋友可以參考一下

復制代碼 代碼如下:

兩個截取字符串的實用方法(超過一定長度自動換行)
///
 /// 截取字符串,不限制字符串長度
 ///
 /// 待截取的字符串
 /// 每行的長度,多于這個長度自動換行
 ///
 public string CutStr(string str,int len)
 { string s="";

 for(int i=0;i 11 {
 int r= i% len;
 int last =(str.Length/len)*len;
 if (i!=0 && i<=last)
 {

 if( r==0)
 {
 s+=str.Substring(i-len,len)+"";
 }

 }
 else if (i>last)
 {
 s+=str.Substring(i-1) ;
 break;
 }

 }

 return s;

 }


 ///
 /// 截取字符串并限制字符串長度,多于給定的長度+。。。
 ///
 /// 待截取的字符串
 /// 每行的長度,多于這個長度自動換行
 /// 輸出字符串最大的長度
 ///
 public string CutStr(string str,int len,int max)
 {
 string s="";
 string sheng="";
 if (str.Length >max)
 {
 str=str.Substring(0,max) ;
 sheng="";
 }
 for(int i=0;i 53 {
 int r= i% len;
 int last =(str.Length/len)*len;
 if (i!=0 && i<=last)
 {

 if( r==0)
 {
 s+=str.Substring(i-len,len)+"";
 }

 }
 else if (i>last)
 {
 s+=str.Substring(i-1) ;
 break;
 }

 }

 return s+sheng;

 }

相關文章

最新評論