手机
当前位置:查字典教程网 >编程开发 >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用户控件技术

ASP.NET JSON字符串与实体类的互转换的示例代码

ASP.NET 2.0 URL映射技巧

ASP.NET 页面间数据传递方法

ASP.NET 2.0写无限级下拉菜单

几个 ASP.NET 小技巧

用ASP.NET还原与恢复Sql server

ASP.NET技巧:为Blog打造个性日历

ASP.NET 数据访问类

ASP.NET存取XML实例代码与注解

精品推荐
分类导航