By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 795 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Find last comma in string

P: n/a
Hello,

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

Thanks,
Miguel
Nov 22 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Fri, 21 Nov 2008 15:57:26 -0800, shapper <md*****@gmail.comwrote:
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
Nov 22 '08 #2

P: n/a
"shapper" <md*****@gmail.comwrote in message
news:df**********************************@33g2000y qm.googlegroups.com...
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

Nov 22 '08 #3

P: n/a
"shapper" <md*****@gmail.comwrote in message
news:df**********************************@33g2000y qm.googlegroups.com...
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".

Nov 22 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.