Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have string like " d,j,k,l,k,"

I want to split it till before the last comma.

output is: ""d,j,k,l,k"
Posted

Easiest way?
C#
string inp = "d,j,k,l,k,";
string oup = inp.TrimEnd(',');
 
Share this answer
 
Comments
sachi Dash 18-Feb-14 4:33am    
can you help me please for another question.

if I want to split it till before the first comma?
OriginalGriff 18-Feb-14 4:44am    
Depends exactly what you are trying to do: there are a lot of ways to do this.
String.Split, String.Substring, Regular expressions, IndexOf, and so forth.

What exactly are you trying to achieve here? Not the specific task of this string, but why are you doing it? What do you want to do with the data when you are finished?
try this
C#
var word=" d,j,k,l,k,";
var parseWord=word.SubString(0,(word.Length-2)); 
 
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