本文介绍了如何分隔两个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从整个字符串中分离出三个字符串,并将其存储到不同的变量中??????
范例:-manager-designer-teamleader
o/p:-jobcat1 =经理
jobcat2 = designer
jobcat3 = teamleader

那么如何为此编写代码???????
请帮助我急.............

i want to seperate three strings from whole string nd store it into different variable??????
example:-manager-designer-teamleader
o/p:-jobcat1=manager
jobcat2=designer
jobcat3=teamleader

so how can write code for this???????
plz help me its urgent.......

推荐答案

string _actualString = "manager-designer-teamleader";
string[] _splitedStringArray = _actualString.Split('-');

//Now if you want to user the job category then use like this
_splitedStringArray[0] ---- it will return  manager
_splitedStringArray[1] ---- it will return  designer
_splitedStringArray[2] ---- it will return  teamleader


string s=manager-designer-teamleader;
string s1[]=s.split(new char[]{'-'})

foreach(string a in s1)
{
response.write(a)
}




其他
你可以这样




else
you can do like this

string a,b,c
string s=manager-designer-teamleader;
string a=s.split(new char[]{''-''})[0]
string b=s.split(new char[]{''-''})[1]
string c=s.split(new char[]{''-''})[2]


这篇关于如何分隔两个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-13 00:59