ASP.NET两个截取字符串的实用方法技巧
来源:互联网 发布:sql server教程 pdf 编辑:程序博客网 时间:2024/04/28 21:21
两个截取字符串的实用方法(超过一定长度自动换行)
1/**////
2 /// 截取字符串,不限制字符串长度
3 ///
4 /// 待截取的字符串
5 /// 每行的长度,多于这个长度自动换行
6 ///
7 public string CutStr(string str,int len)
8 { string s="";
9
10 for(int i=0;i 11 {
12 int r= i% len;
13 int last =(str.Length/len)*len;
14 if (i!=0 && i<=last)
15 {
16
17 if( r==0)
18 {
19 s+=str.Substring(i-len,len)+"
";
20 }
21
22 }
23 else if (i>last)
24 {
25 s+=str.Substring(i-1) ;
26 break;
27 }
28
29 }
30
31 return s;
32
33 }
34
35
36 /**////
37 /// 截取字符串并限制字符串长度,多于给定的长度+。。。
38 ///
39 /// 待截取的字符串
40 /// 每行的长度,多于这个长度自动换行
41 /// 输出字符串最大的长度
42 ///
43 public string CutStr(string str,int len,int max)
44 {
45 string s="";
46 string sheng="";
47 if (str.Length >max)
48 {
49 str=str.Substring(0,max) ;
50 sheng="";
51 }
52 for(int i=0;i 53 {
54 int r= i% len;
55 int last =(str.Length/len)*len;
56 if (i!=0 && i<=last)
57 {
58
59 if( r==0)
60 {
61 s+=str.Substring(i-len,len)+"
";
62 }
63
64 }
65 else if (i>last)
66 {
67 s+=str.Substring(i-1) ;
68 break;
69 }
70
71 }
72
73 return s+sheng;
74
75 }
- ASP.NET两个截取字符串的实用方法技巧
- ASP.NET技巧:两个截取字符串的实用方法
- 两个截取字符串的实用方法
- 两个截取字符串的实用方法
- ASP.NET两个截取字符串的方法分享
- asp.net截取字符串方法
- 截取字符串的两个方法
- 两个截取字符串的实用方法(超过一定长度自动换行)
- asp.net 截取带有html标签的字符串(先过滤html,再截取)的方法
- asp.net截取字符串
- Javascript截取字符串的两个方法
- Javascript截取字符串的两个方法
- javascript截取字符串的两个方法
- Javascript截取字符串的两个方法[载]
- Javascript截取字符串的两个方法
- Asp.Net截取两个相同字符之间的字符串内容(示例)
- 关于asp.net的字符串截取
- ASP.NET中过滤HTML字符串的两个方法
- 上传 下载简单功能
- 希腊字母读法
- 需求分析的格式
- SQL按月汇总
- Asp.Net 建立一个在线 RSS 新闻聚合器
- ASP.NET两个截取字符串的实用方法技巧
- ASP.NET中显示Linq To SQL输出的SQL语句
- 刚从网上找的一个学生数据管理系统的代码。
- struts1与2区别
- Android 根文件系统分析(2)
- 终结者2018,Everybody Deserved Second Chance
- 关于笛卡尔积、全连接测试
- DBA常用SQL查询
- Ubuntu声音不正常的解决办法