Connecting Tech Pros Worldwide Forums | Help | Site Map

Find last comma in string

shapper
Guest
 
Posts: n/a
#1: Nov 22 '08
Hello,

I need to replace the last comma in a string by " and ". How can I do
this?

Thanks,
Miguel

Peter Duniho
Guest
 
Posts: n/a
#2: Nov 22 '08

re: Find last comma in string


On Fri, 21 Nov 2008 15:57:26 -0800, shapper <mdmoura@gmail.comwrote:
Quote:
Hello,
>
I need to replace the last comma in a string by " and ". How can I do
this?
http://msdn.microsoft.com/en-us/libr...stindexof.aspx

That link will help you solve the first half of the problem. I leave it
as an exercise for you to solve the second half, but I'll provide a hint:
generally speaking, if you want to know what you can do with an instance
of String, you should look at the "Class Members" documentation page on
MSDN. Often you will find that there is already method to accomplish your
goal or, at the very least, one that would be helpful.

You could have answered the first half of this question by using that
hint, and you should be able to answer the second half by doing so as well.

Pete
Mark Rae [MVP]
Guest
 
Posts: n/a
#3: Nov 22 '08

re: Find last comma in string


"shapper" <mdmoura@gmail.comwrote in message
news:df9dc6f8-44d7-4b1b-8773-1e37cf197310@33g2000yqm.googlegroups.com...
Quote:
I need to replace the last comma in a string by " and ". How can I do
this?
http://msdn.microsoft.com/en-us/libr...stindexof.aspx
http://msdn.microsoft.com/en-us/library/aka44szs.aspx
http://msdn.microsoft.com/en-us/libr...g.replace.aspx


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Family Tree Mike
Guest
 
Posts: n/a
#4: Nov 22 '08

re: Find last comma in string


"shapper" <mdmoura@gmail.comwrote in message
news:df9dc6f8-44d7-4b1b-8773-1e37cf197310@33g2000yqm.googlegroups.com...
Quote:
Hello,
>
I need to replace the last comma in a string by " and ". How can I do
this?
>
Thanks,
Miguel

Does your list potentially contain currency strings? If so, I hope that one
of your test strings is "$3,000.00, $4,000.00, $5,000.00".

Closed Thread


Similar C# / C Sharp bytes