All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
XMLHTTPRequest的属性和方法简介_[XML教程]
XP上安装SqlServer2000_[SQL Server教程]
如何设置限制sqlserver占据内存问题_mssql学习_编程技术
HTML 初学者指南(2)_[Html教程]
ASP.NET,2.0中XML数据的处理_[Asp.Net教程]
ASP.NET技巧:两个截取字符串的实用方法_.net资料_编程技术
基础知识:PHP连接mysql测试和配置_php资料_编程技术
Asp.Net图片验证码程序[含源码]_[Asp.Net教程]
delphi结构化异常处理
5种易犯的PHP数据库错误_[PHP教程]
Reading number is top 10 pictures
不知名的美女素颜照1
这才叫绝色美女2
The real super beauty10
The terra-cotta warriors2
西方气质的东方美女2
如果没有好报,为什么要做好人?
29 the belle stars after bath figure1
每天进步一点点
A man's favorite things12
西游四格漫画(二)
Download software ranking
I'm come from Beijing1
ASP.NET.2.0.XML.高级编程(第3版)
致我们终将逝去的青春
徐若瑄成名作“魔鬼天使”
The Bermuda triangle3
Unix video tutorial12
Eclipse 4.2.1 For Win32
C#COM编程指南
Tram sex maniac 2 (H) rar bag17
金山office2007
aaa published in(发表于) 2013/12/8 7:50:51 Edit(编辑)
ASP.NET技巧:两个截取字符串的实用方法_.net资料_编程技术

ASP.NET技巧:两个截取字符串的实用方法_.net资料_编程技术

ASP.NET技巧:两个截取字符串的实用方法_.net资料_编程技术-你的首页-uuhomepage.com

  两个截取字符串的实用方法(超过一定长度自动换行)


1/**////


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

4 /// 待截取的字符串
5 /// 每行的长度,多于这个长度自动换行
6 ///
7 public string CutStr(string str,int len)
8 { string s="";
9
10 for(int i=0;i11 {
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;i53 {
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 }






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.