Remove a Comma in String Value

T.saravanan
Posted by T.saravanan under C# category on | Points: 40 | Views : 8362
Hi,

Remove Last Comma in a String Value

string sValue="A,B,C,D,E,"; // Input
sValue=sValue.Remove(sValue.LastIndexof(","),1);
// Now we get
sValue="A,B,C,D,E"; // Output


Thanks,
T.Saravanan :)

Comments or Responses

Posted by: Lakhangarg on: 8/22/2010 Level:Silver | Status: [Member] [Moderator] | Points: 10
Hi,

You Can also use
sValue.TrimEnd(',');


Regards,
Lakhan Pal Garg


Login to post response