手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >ASP.NET两个截取字符串的方法分享
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;

}

【ASP.NET两个截取字符串的方法分享】相关文章:

ASP.NET 用户多次登录的解决方法

ASP.NET实现推送文件到浏览器的方法

ASP.NET 中文显示之两种解决方法

ASP.net中md5加密码的方法

ASP.NET 重定向的几种方法小结

asp.net字符串分割函数使用方法分享

ASP.NET MVC3 实现全站重定向的简单方法

ASP.Net防止刷新自动触发事件的解决方案

ASP.NET 2.0下随机读取Access记录的实现方法

ASP.NET编程中的十大技巧

精品推荐
分类导航