Click here to Skip to main content
15,898,979 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.......
Posted

C#
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
 
Share this answer
 
v2
Comments
member60 16-Jun-12 7:51am    
my 5!
hai try this

C#
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]
 
Share this answer
 
v5
Comments
Philippe Mori 16-Jun-12 7:45am    
It make no sense to make an "expensive" operation 3 times (in the second sample). And the " " around the string are missing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900