手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >ASP.NET 字符串截取
ASP.NET 字符串截取
摘要:复制代码代码如下:**///////截取字符串,不限制字符串长度//////待截取的字符串///每行的长度,多于这个长度自动换行///pub...

复制代码 代码如下:

**////

/// 截取字符串,不限制字符串长度

///

/// 待截取的字符串

/// 每行的长度,多于这个长度自动换行

///

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中TimeSpan的用法

ASP.NET热点问题解答14个

ASP.NET 创建带事件的用户控件

ASP.NET中集成百度编辑器UEditor

ASP.NET中实现模板页

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

ASP.NET 2.0,C#----图像特效处理

ASP.NET用户控件技术

ASP.NET 2.0 中的创建母版页

ASP.NET中TreeView用法

精品推荐
分类导航