something about deal with string
来源:互联网 发布:worldwind java 教程 编辑:程序博客网 时间:2024/05/22 04:25
in our project,we have to spend a lot of care on deal with string.now ,i want to say some method in string class in c#.
in c# ,string provide remove,substring,insert method to transact string.look a example,now if we want to change "1984:12:21:*" to "1984122100" code is:
string ss = "1984:*:21:*";
int i = 0;
int count = 0;
for (i = 0; i < ss.Length; i++)
{
if (ss.Substring(i, 1) == ":")
{
count++;
ss = ss.Remove(i, 1);
if (ss.Substring(i - 1, 1) == "*")
{
int count = 0;
for (i = 0; i < ss.Length; i++)
{
if (ss.Substring(i, 1) == ":")
{
count++;
ss = ss.Remove(i, 1);
if (ss.Substring(i - 1, 1) == "*")
{
switch (count)
{
case 1:
ss = ss.Remove(i - 1, 1);
ss = ss.Insert(i - 1, "0000");
i = 0;
break;
case 2:
ss = ss.Remove(i - 1, 1);
ss = ss.Insert(i - 1, "00");
i = 0;
break;
case 3:
ss = ss.Remove(i - 1, 1);
ss = ss.Insert(i - 1, "00");
i = 0;
break;
case 4:
ss = ss.Remove(i - 1, 1);
ss = ss.Insert(i - 1, "00");
i = 0;
break;
default:
break;
}
}
}
}
if (ss.Substring(ss.Length - 1, 1) == "*")
{
ss = ss.Remove(ss.Length - 1, 1);
ss = ss.Insert(ss.Length - 1, "00");
}
}
}
}
through this code ,we complish change ;we just used remove,insert,substring method,so i think if you are c# coder, you are very luck ,because we just waste a littele time can deal with string.
- something about deal with string
- Something about String,substring
- Something about ...
- strcpy deal with overlapping
- android error deal with
- python deal with mysql
- Something about float divide
- something about Tomcat(zz)
- something about Listeners
- something about Macro
- Something about Music
- something about struts
- something about ado
- something about SEO
- Something About Pretect Mode
- something about this week
- Something about Ajax
- something about Ajax Ⅱ
- Coalition, Iraqi Forces Work to Halt Cycle of Violence in Baghdad
- U.S., Russian Leaders Agree to Meet Again
- Guard Works to Bring Back Prior-Service Soldiers
- Troops Kill 13 Insurgents; Car Bombs Kill, Injure Iraqis
- Stryker Cavalry Ridding Baghdad of Bombs, ‘Bad Guys’
- something about deal with string
- IBM to track mainframe power use
- ASP.NET中WEB用户控件和自定义控件
- 哥斯达黎加 百天快速移民、入藉
- 基 因 检 测 感 想
- 基因检测的市场价值
- Linux那些事儿之我是UHCI(6)来来,我是一条总线,线线线线线线
- 基因检测——二十一世纪最时尚的健康方式和财富通道
- 基因检测深远的意义