String.Replace

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is wrong with the following:

dim a as string = "This is a new String"
a.Replace("new", "old")

When this code is executed, a remains as per the original, i.e., "This is a
new String"
 
Hi,

String.replace returns a string. Try this
a=a.replace("new","old")

Ken
------------------------
What is wrong with the following:

dim a as string = "This is a new String"
a.Replace("new", "old")

When this code is executed, a remains as per the original, i.e., "This is a
new String"
 
The Replace method returns a string. If you ignore the return value,
you're sending the method output "into thin air".

So, you want:

im a as string = "This is a new String"
a = a.Replace("new", "old")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top