Click here to Skip to main content
15,912,457 members
Please Sign up or sign in to vote.
1.27/5 (3 votes)
See more:
string a="13,14,18,/22,23,28,"

output should be:
string C="13,14,18,"
string d="22,23,28,"

how can i do this in C#
Posted
Updated 13-Jun-13 2:08am
v2
Comments
[no name] 13-Jun-13 8:05am    
Did you try Split?
Member 9693918 13-Jun-13 8:05am    
please help me.. as soon as possible

Use String.Split()[^] function to do that.
C#
string a="13,14,18,/22,23,28,";
string[] result = a.Split('/');//Now this array will contain two strings "13,14,18," and "22,23,28,". You can loop through the array and use the values.

[Edit 1]
Assign the selected value in variable
C#
string C = result[0];
string D = result[1];



--Amit
 
Share this answer
 
v3
Comments
Member 9693918 13-Jun-13 8:09am    
thanks
_Amy 13-Jun-13 8:10am    
Welcome. :)
Try this way:
C#
string a="13,14,18,/22,23,28,"
string C = a.Split('/')[0];
string d = a.Split('/')[1];
 
Share this answer
 
C#
string a = "13,14,18,/22,23,28,";
string[] temp=a.Split('/');

string C = temp[0];
string d = temp[1];
 
Share this answer
 

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