Link to home
Start Free TrialLog in
Avatar of michael1174
michael1174Flag for United States of America

asked on

Replace all instances

Hello, I'm trying to replace all instances of, for example, the > sign in a string.

I know I can do a string.replace(">",">").  But this only replaces once instance.  What is the best way that I can replace all instances?

I've tried, but for some reason its not working and my text has alot of amp; in it after its done processing.

foreach (char c in value)
   {
       value = Replace(">", ">");
   }
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of michael1174

ASKER

HttpServerUtility.HtmlEncode is exactly what I needed, thank you.
Hello, I am using the Server.HtmlEncode but for some reason if a wierd string like "!@#$%^&*()_+-={}|[]\:";'<>?,./" (without the quotes) is passed in, the html is not structured correctly.

Do you have any other suggestions?